// // Check function to see if Morg should hunt potential prey. // public bool toHunt(Morg hunter, Morg prey) { if (hunter.getMorgtype() == 'A' && (prey.getMorgtype() == 'B' || prey.getMorgtype() == 'C') && prey.getLiving()) return true; if (hunter.getMorgtype() == 'B' && prey.getMorgtype() == 'A' && prey.getLiving()) return true; if (hunter.getMorgtype() == 'C' && (prey.getMorgtype() == 'A' || prey.getMorgtype() == 'B') && prey.getLiving()) return true; else return false; }
// //Assigns prey to Morg if non null value prey passed in // public void setPrey(Morg newPrey) { prey = newPrey; if (newPrey != null) { isfollowing = true; prey.registerObserver(this); } else isfollowing = false; }
// //Simulator constructor // public Simulator(Morg morg1, Morg morg2, Morg morg3) { morgList = new List<Morg>(); morgList.Add(morg1); morgList.Add(morg2); morgList.Add(morg3); Random rnd = new Random(); foreach ( Morg element in morgList) { int locX = rnd.Next(0, 9); int locY = rnd.Next(0, 9); element.setLocation(locX, locY); } }
// //feed behaviour for morg class // public void feed(Morg prey) { Console.WriteLine( name + " will" ); feedBehavior.feed(); Console.WriteLine(prey.name + "!"); }