示例#1
0
文件: Patient.cs 项目: scryptan/cs2
 protected Patient(IVirus virus, Action infected, Action recovered, Action dead)
 {
     Virus      = virus;
     _infected  = infected;
     _recovered = recovered;
     _dead      = dead;
 }
示例#2
0
        internal static IVirus CreateVirus(string id, int threatlevel)
        {
            if (threatlevel < 1)
            {
                throw new Exception("Threat level can't be below 1.");
            }
            if (threatlevel > 4)
            {
                throw new Exception("Threat level can't be above 4.");
            }

            foreach (var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IVirus)) && Shiftorium.UpgradeAttributesUnlocked(x)))
            {
                var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is VirusAttribute) as VirusAttribute;
                if (attrib != null)
                {
                    if (attrib.ID == id)
                    {
                        IVirus virus = (IVirus)Activator.CreateInstance(type);
                        virus.Infect(threatlevel);
                        return(virus);
                    }
                }
            }

            throw new Exception("Cannot create virus.");
        }
示例#3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            List <IVirus> virusi = new List <IVirus>();

            cb_tip.DataSource = new List <string>()
            {
                "Corona", "Gripa"
            };

            bt_spremi.Click += (o, a) =>
            {
                IVirus virus = null;

                switch (cb_tip.SelectedItem.ToString())
                {
                case "Corona":
                    Corona corona = new Corona();     // IVurus as Corona
                    corona.Mutacija = "Britanski soj";
                    virus           = corona;
                    break;

                case "Gripa":
                    virus = new Gripa();
                    break;
                    //...
                }
                virus.EvidentirajZarazene(Int64.Parse(tb_broj.Text), calendar.SelectionStart.Date);
                virusi.Add(virus);
                virusi.Sort();
                lb_svi_virus.Text = "Evidencija:";
                foreach (IVirus v in virusi)
                {
                    lb_svi_virus.Text += "\n" + v;
                }
            };
        }
示例#4
0
 public NormalPatient(IVirus virus, Action infected, Action recovered, Action dead) : base(virus, infected, recovered, dead)
 {
     InfectOffset   = 10;
     RecoveryOffset = 5;
     DeadOffset     = 0;
 }
示例#5
0
 public VirusController(INiveauBeheer niveauContext, IVirus virus, ILandBeheer landContext)
 {
     _virus         = (Virus)virus;
     _niveauContext = niveauContext;
     _landContext   = landContext;
 }
示例#6
0
 public int CompareTo(IVirus other)
 {
     return(this._brojZarazenih.CompareTo(other.BrojZarazenih));  // Sve u jednoj liniji sa ugrađenom metodom
 }
示例#7
0
 public ImmunityController()
 {
     virus   = new CoronaVirus();
     Patient = new NormalPatient(virus, Infected, Recovered, Dead);
 }