public static void Main() { Camera pentax = new Camera("Pentax"); WaterPistol pistol = new WaterPistol("Supersoaker"); LaserGun laserGun = new LaserGun("Acme"); Hunter nish = new Hunter("Nish", "Mandal", pentax); Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); nish.Shooter = laserGun; Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); }
public static void Main() { LaserGun gun1 = new LaserGun("Cod"); LaserGun gun2 = new LaserGun("WorldWarZ"); WaterPistol gun3 = new WaterPistol("Supersoaker"); Camera gun4 = new Camera("Polaroid"); Camera gun5 = new Camera("Nikon"); Hunter hunter1 = new Hunter("Vinay", "Patel", gun1); Hunter hunter2 = new Hunter("Vinay", "Patel", gun3); Hunter hunter3 = new Hunter("Vinay", "Patel", gun5); List <IShootable> Guns = new List <IShootable>(); Guns.Add(gun1); Guns.Add(gun2); Guns.Add(gun3); Guns.Add(gun4); Guns.Add(gun5); Guns.Add(hunter1); Guns.Add(hunter2); Guns.Add(hunter3); foreach (var item in Guns) { Console.WriteLine(item.Shoot()); } Console.WriteLine(""); Camera pentax = new Camera("Pentax"); WaterPistol pistol = new WaterPistol("Supersoaker"); LaserGun laserGun = new LaserGun("Acme"); Hunter nish = new Hunter("Nish", "Mandal", pentax); Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); nish.Shooter = laserGun; Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; }
static void Main(string[] args) { //instantiating two objects from the Person class //Person bruno = new Person("Bruno", "Silva"); //bruno.Age = 23; //Console.WriteLine($"Bruno is {bruno.Age}"); ////Console.WriteLine(bruno.GetFullName()); ////Person nish = new Person("Nish", "French"); ////Console.WriteLine(bruno.GetFullName ////overloading constructor instance ////Person luis = new Person("Luis", "Wolton", 23); ////Console.WriteLine(luis.Age); ////structs //var s1 = new Point3D() { x = 1, y = 2, z = 3 }; //Person john = new Person("John", "Jones") { Age = 20 }; //Point3D pt3d = new Point3D(5, 8, 2); //DemoMethod(pt3d, john); //Hunter bruno = new Hunter("Bruno", "Silva", "nikon") { Age = 23 }; //Console.WriteLine(bruno.Age); //Console.WriteLine(bruno.Shoot()); //default inherited construction //Hunter bruno2 = new Hunter(); //Console.WriteLine(bruno2.Age); //Console.WriteLine(bruno2.Shoot()); //create a list of objects //Person bruno1 = new Person("Bruno", "Silva") { Age = 23 }; //Hunter nish = new Hunter("Nish", "French", "nikon") ; //MonsterHunter luis = new MonsterHunter("Luis", "Wolton", "nikon", "fists"); //var safariList = new List<object>(); //safariList.Add(bruno1); //safariList.Add(nish); //safariList.Add(luis); //foreach(var obj in safariList) //{ // Console.WriteLine(obj.ToString()); //} //Airplane air = new Airplane(200, 100, "JetRUs") { NumPassengers = 150 }; //air.Ascend(500); //Console.WriteLine(air.Move(3)); //Console.WriteLine(air); //air.Descend(200); //Console.WriteLine(air.Move()); //air.Move(); //Console.WriteLine(air); //working with Polymorphism //var bruno = new Person("Bruno", "Silva"); //var boeing = new Airplane(400, 200, "Boeing"); //var v1 = new Vehicle(12, 20); //var phil = new Hunter("Phil", "Anderson", "Pentax"); ////make a list that only contains objects that use IMovable methods //var moveObj = new List<IMovable>() //{ // new Person("Chen", "Shan"), // new Airplane(400, 200, "RyanAir"), // new Vehicle(6, 10), // new Hunter("Croc", "Dundee", "Nikon") //}; //Console.WriteLine(); //Console.WriteLine("Moving objects"); //foreach(var item in moveObj) //{ // Console.WriteLine(item.Move(3)); //} //var gameObject = new List<Object>() //{ // bruno, // boeing, // v1, // phil //}; //foreach(var item in gameObject) //{ // Console.WriteLine(item); //} //SpartaWrite(phil); //SpartaWrite(bruno); //public static void SpartaWrite(object obj) //{ // Console.WriteLine(obj); // if(obj is Hunter) // { // var HunterObj = (Hunter)obj; // Console.WriteLine(HunterObj.Shoot()); // } //} //Polymorphism homework tast, using interface and inheritance Camera pentax = new Camera("Pentax"); WaterPistol pistol = new WaterPistol("SuperSoaker"); LaserGun laserGun = new LaserGun("Acme"); Hunter nish = new Hunter("Nish", "Mandal", pentax); Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); nish.Shooter = laserGun; Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); }
static void Main(string[] args) { //Person leonard = new Person("Leonard", "Atorough"); //leonard.Age = 23; //Console.WriteLine(leonard.GetFullName()); //Person raheel; //raheel = new Person("Raheel", "Ahmed") { Age = -24 }; //Console.WriteLine(raheel.GetFullName()); //Spartan lenny = new Spartan("Lenny", "Ato"); //Console.WriteLine($"{lenny.FirstName} {lenny.LastName}"); //ShoppingList list = new ShoppingList() { Bread = 3 }; //list.Milk = 43; //var newList = new ShoppingList(); //list.Bread = 12; //list.Lemon = 31; //Person mansib = new Person("Mansib", "Raham") { Age = 20 }; //Point3D p3d = new Point3D(3, 4, 9); //MyMethod(p3d, mansib); //static void MyMethod (Point3D p3, Person p) //{ // p3.y = 1000; // p.Age = 92; //} //Hunter bill = new Hunter("Bill", "Clinton", "Lecia") { Age = 62 }; //Console.WriteLine(gino.Shoot()); //var billy = new Hunter("Billy", "Hilly", "Canon") { Age = 42 }; //Console.WriteLine($"Bill equal Billy? {bill.Equals(billy)}"); //Console.WriteLine($"Bill's hascode: {bill.GetHashCode()}"); //Console.WriteLine($"Billy's type: {billy.GetType()}"); //Console.WriteLine($"Billy to string: {billy.ToString()}"); //List<IMovable> gameObjects = new List<IMovable>() //{ // new Person ("Leon", "Vance"), // new Airplane(300, "Lufthansa", 800), // new Vehicle(20, 80, 40) //}; //foreach (var gameObject in gameObjects) //{ // Console.WriteLine(gameObject.Move()); //} //foreach (var gameObject in gameObjects) //{ // Console.WriteLine(gameObject.Move(4)); //} // var topCat = new Person("Top", "Cat"); // var hunterCat = topCat as Hunter; //} //static void SpartaWrite (object obj) //{ // Console.WriteLine(obj.ToString()); // if (obj is Hunter) // { // var hunter = (Hunter)obj; // Console.WriteLine(hunter.Shoot()); //} //var shooters = new List<IShootable>() //{ // new LaserGun("Bolt SMG"), // new LaserGun("M-Star"), // new WaterPistol("BubbleMax 2000"), // new WaterPistol("Jetsteam X"), // new Hunter("Alan", "Quartermaine", new LaserGun("LR-77")), // new Hunter("Steve", "Backshaw", new Camera("Kenon Scenefinder")) //}; //foreach (var item in shooters) //{ // Console.WriteLine(item.Shoot()); //} //Console.WriteLine(); //foreach (var item in shooters) //{ // Console.WriteLine(item.ToString()); //} Hunter alan = new Hunter("Alan", "Quartermaine", new LaserGun("HeatGun")); Hunter rish = new Hunter("Rish", "Sunak", new Camera("Nikon")) { Health = 2 }; Console.WriteLine($"Rish's health is {rish.Health}"); alan.Shoot(rish); rish.Shoot(alan); Console.WriteLine($"Rish's health is {rish.Health}"); }
static void Main(string[] args) { //Person cathy = new Person("Cathy", "French"); //Console.WriteLine(cathy.GetFullName()); //Person nish; //nish = new Person("Nish", "Mandal"); //Console.WriteLine(nish.GetFullName()); //cathy.Age = 22; //Console.WriteLine($"Cathy is {cathy.Age}"); //cathy.Age = -3; //Console.WriteLine($"Cathy is {cathy.Age}"); //Hunter h = new Hunter("Marion", "Jones", "Leica") { Age = 32 }; //Console.WriteLine(h.Age); //Console.WriteLine(h.Shoot()); //Hunter h2 = new Hunter(); //Console.WriteLine(h2.Shoot()); //var h3 = new Hunter("Marion", "Jones", "Leica") { Age = 32 }; //Console.WriteLine($"h Equals h3? {h.Equals(h3)}"); //Console.WriteLine($"h HashCode: {h.GetHashCode()}"); //Console.WriteLine($"h Type: {h.GetType()}"); //Console.WriteLine($"h ToString: {h.ToString()}"); //Console.WriteLine($"h:{h}"); //Airplane a = new Airplane(200, 100, "JetsRUs") { NumPassengers = 150 }; //a.Ascend(500); //Console.WriteLine(a.Move(3)); //Console.WriteLine(a); //a.Descend(200); //Console.WriteLine(a.Move()); //a.Move(); //Console.WriteLine(a); //List<Object> gameObjects = new List<Object>() //{ // new Person("Cathy","French"), //new Airplane(400, 200, "Booing"), //new Vehicle(12,20), //new Hunter("Henry","Hodgkins","Pentax") //}; //foreach(var gameObj in gameObjects) //{ // SaprtaWrite(gameObj); //} //List<IMovable> gameInterfaces = new List<IMovable>() //{ //new Person("Cathy","French"), //new Airplane(400, 200, "Booing"), //new Vehicle(12,20), //new Hunter("Henry","Hodgkins","Pentax") //}; //foreach (var gameInterface in gameInterfaces) //{ // Console.WriteLine(gameInterface.Move()); // Console.WriteLine(gameInterface.Move(10)); // //Console.WriteLine(gameInterface); //} //List<IShootable> gameWeapons = new List<IShootable>() //{ //new LaserGun("Laser Gun"), //new WaterPistol("Water Pistol"), //new Hunter("Henry","Hodgkins",new Camera("Kodak")), //new Camera("Pentax") //}; //foreach (var gameWeapon in gameWeapons) //{ // Console.WriteLine(gameWeapon.Shoot()); // //Console.WriteLine(gameInterface); //} Camera pentax = new Camera("Pentax"); WaterPistol pistol = new WaterPistol("Supersoaker"); LaserGun laserGun = new LaserGun("Acme"); Hunter nish = new Hunter("Nish", "Mandal", pentax); Hunter sully = new Hunter("Sully", "Miah", pistol); Console.WriteLine(sully.Shoot()); Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; sully.Shooter = laserGun; Console.WriteLine(nish.Shoot()); Console.WriteLine(sully.Shoot()); nish.Shooter = laserGun; Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); }
static void Main(string[] args) { //Person cathy = new Person("Cathy", "French"); //cathy.Age = 20; //Console.WriteLine(cathy.GetFullName()); //Person nish; //nish = new Person("Nish", "Mandal") { Age = 30 }; //Age is an object initialiser //Console.WriteLine(nish.GetFullName()); //Person Jino = new Person("Jino", "Bimpa") { Age = 20 }; //Point3D pt3D = new Point3D(5, 8, 2); //DemoMethod(pt3D, Jino); //Hunter lauren = new Hunter("Lauren", "Pang", "Leica") { Age = 20 }; //Console.WriteLine(lauren.Age); //Console.WriteLine(lauren.Shoot()); //Console.WriteLine(lauren.GetFullName()); //Hunter h = new Hunter(); //Console.WriteLine(h.Shoot()); //var kam = new Hunter("Kam", "Sohal", "Nikon") { Age = 25 }; //Console.WriteLine($"Kam Equals Lauren? {kam.Equals(lauren)}"); //Console.WriteLine($"Kam HashCode: {kam.GetHashCode()}"); //Console.WriteLine($"Kam Type: {kam.GetType()}"); //Console.WriteLine($"Kam ToString: {kam.ToString()}"); //Airplane a = new Airplane(200, 100, "JetsRUs") { NumPassengers = 150 }; //a.Ascend(500); //Console.WriteLine(a.Move(3)); //Console.WriteLine(a); //a.Descend(200); //Console.WriteLine(a.Move()); //a.Move(); //Console.WriteLine(a); //var dom = new Hunter("Dom", "Newell", "Kodak"); //var geoff = new Hunted("Geoff", "Jefferson", 3); //Console.WriteLine(dom.Shoot(geoff)); //var nish = new Hunter("Nish", "Mandal") { Age = 30 }; //SpartaWrite(nish, geoff); //List<object> gameObjects = new List<object>() //{ // new Person ("Cathy", "French"), // new Airplane(400, 100, "Vorgon"), // nish, // new Vehicle(12, 40) //}; //foreach(var gameObj in gameObjects) //{ // Console.WriteLine(gameObj.ToString()); //} //var movingObj = new List<IMovable>() //{ // new Vehicle(), // new Person(), // new Airplane(), // new Hunter(), // new Hunted(), // new Person(), // new Airplane(), // new Hunter() //}; //foreach (var item in movingObj) //{ // Console.WriteLine(item.Move()); //} //var shooties = new List<IShootable>() //{ // new WaterPistol("Nerf"), // new LaserGun("ACME"), // new WaterPistol("Super Soaker"), // new LaserGun("DeathLazerz"), // new Hunter(), // new Hunter(), // new Camera("Pentax") //}; //foreach (var item in shooties) //{ // Console.WriteLine(item.Shoot()); //} Console.WriteLine("Polymorphic Shootout\n\n"); Camera pentax = new Camera("Pentax", 0); WaterPistol pistol = new WaterPistol("SuperSoaker", 1); LaserGun laserGun = new LaserGun("Acme", 2); SpaceGun space = new SpaceGun("Martian", 3); Hunter dom = new Hunter("Dom", "Newell", pistol, 10); Hunter geoff = new Hunter("Geoff", "Jefferson", pistol, 10); var nextTurn = new Random(); var weaponChange = new Random(); while (dom.Health > 0 && geoff.Health > 0) { if (nextTurn.Next(2) == 1) { switch (weaponChange.Next(4)) { case 0: dom.Shooter = laserGun; break; case 1: dom.Shooter = pistol; break; case 2: dom.Shooter = space; break; default: dom.Shooter = pentax; break; } Console.WriteLine(dom.Shoot(geoff, dom) + "\n"); } else { switch (weaponChange.Next(4)) { case 0: geoff.Shooter = laserGun; break; case 1: geoff.Shooter = pistol; break; case 2: geoff.Shooter = space; break; default: geoff.Shooter = pentax; break; } Console.WriteLine(geoff.Shoot(dom, geoff) + "\n"); } } }
static void Main(string[] args) { Point3D hunterPosition = new Point3D(2, 0, 1); Bow bow = new Bow("Wood", 3); Camera pentax = new Camera("Lego"); WaterPistol pistol = new WaterPistol("Nerf"); LaserGun laserGun = new LaserGun("project3005"); Hunter tera = new Hunter("Tera", "Sm", hunterPosition, pistol); Console.WriteLine(tera.Shoot()); tera.Shootable = pentax; Console.WriteLine(tera.Shoot()); tera.Shootable = bow; Console.WriteLine(tera.Shoot()); tera.Shootable = laserGun; Console.WriteLine(tera.Shoot()); tera.Shootable = bow; Console.WriteLine(tera.Shoot()); //List<IMoveable> Iobject = new List<IMoveable>() //{ // new Person("Neil","Neil"), // new Vehicle() //}; //foreach (var Iobj in Iobject) //{ // Console.WriteLine(Iobj.Move()); // Console.WriteLine(Iobj.Move(1)); //} Point3D tigerPosition = new Point3D(4, 0, 4); // Point3D hunterPosition = new Point3D(2, 0, 1); Tiger tiger = new Tiger(Animals.animalType.aerial, 20, 40, tigerPosition, 3); Hunter hunter = new Hunter("Jino", "Biba", hunterPosition, bow); Point3D tigerNewPosition = new Point3D(3, 0, 1); string input = ""; Console.WriteLine("Hi Tiger, There is a hunter nearby! \n"); Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.WriteLine(""); while (true) { Console.WriteLine("Press 'i' to get the hunters info"); Console.WriteLine("Press 'a' to Attack the hunter"); Console.WriteLine("Press 'm' to Move closer to the hunter"); Console.WriteLine("Press 'e' to Run\n"); Console.WriteLine($"Your Position On Safari is X: {tiger.Position.X} Y: {tiger.Position.Y} Z: {tiger.Position.Z}\n"); input = Console.ReadLine(); switch (input) { case "i": Console.WriteLine($"Name: {hunter.GetFullName()}, Health: {hunter.Health}," + $" Position On Safari X: {hunter.Position.X} Y: {hunter.Position.Y}, Z: {hunter.Position.Z}\n"); break; case "a": tiger.Attack(hunter); if (hunter.Health > 0) { Console.WriteLine($"{hunter.Shoot()}\n"); tiger.Health -= bow.Damage; Console.WriteLine($"The Hunter Shot you with a Bow, and inflicted {bow.Damage} Damage\nYour Hp now Is {tiger.Health}\n"); } break; case "m": tiger.Move(tigerNewPosition); Console.WriteLine("You moved Closer, Try Attacking! \n"); break; case "e": if (hunter.Health <= 0) { Console.WriteLine("Thank you for taking down the hunters. \nSee you next time!"); } else { Console.WriteLine("You Chose to Run Away. Nice move :p"); } Environment.Exit(0); break; } } ///// // tiger.Attack(hunter); //Point3D tigerNewPosition = new Point3D(3, 0, 1); //tiger.Move(tigerNewPosition); //tiger.Attack(hunter); //tiger.Attack(hunter); //tiger.Attack(hunter); //// /// //List<object> gameObject = new List<object>() //{ // new Hunter("Ema","Smith",tigerNewPosition), // new Tiger(Animals.animalType.ground,100,30,tigerNewPosition,2), // new Vehicle() //}; //var ema = new Hunter("Ema", "Smith", tigerNewPosition); //foreach (var gameObj in gameObject) //{ // Console.WriteLine(gameObj.ToString()); //} //SpartaWrite(ema); //Airplane a = new Airplane(200, 100, "JetsRUs") { NumPassengers = 150 }; //a.Ascend(500); //Console.WriteLine(a.Move(3)); //Console.WriteLine(a); //a.Descend(200); //Console.WriteLine(a.Move()); //a.Move(); //Console.WriteLine(a); //Person jino = new Person("Jino", "Biba") {Age= 25}; //Console.WriteLine(jino.GetFullName()); //Person cathy; //cathy = new Person("Cathy","French"); //cathy.Age = 20; //Console.WriteLine(cathy.GetFullName()+" "+cathy.Age); //Spartan spartan = new Spartan("Takis","Lakis"); //Console.WriteLine(spartan.FirstName); //Console.WriteLine(spartan.LastName); //var list = new ShoppingList() {Bread =2, Potato =3 }; //list.Lemon = 5; //var list2 = new ShoppingList(); //list2.Milk = 5; //var milkAmount = list2.Milk; //Person jinakos = new Person("Jino", "Bimpa") { Age = 20 }; //Point3D pr3D = new Point3D(5, 8, 2); //DemoMethod(pr3D, jinakos); //Hunter lauren = new Hunter("Lauren", "Pang", "Leica") {Age=20 }; //Console.WriteLine(lauren.Shoot()); //Console.WriteLine(lauren.Age); //Console.WriteLine(lauren.GetFullName()); //Hunter h = new Hunter(); //Console.WriteLine(lauren.ToString()); }
public static void Main() { //Hunter bryn = new Hunter("Bryn", "Morley", "Sony") { Age = 25 }; //Console.WriteLine(bryn); //Console.WriteLine(bryn.Age); //Console.WriteLine(bryn.Shoot()); //Person nish = new Person("Nish", "Mandal"); //Hunter cathy = new Hunter("Cathy", "French", "Nikon"); //MonsterHunter phil = new MonsterHunter("Phil", "Anderson", "Nikon", "Love"); //var safariList = new List<Hunter>(); //safariList.Add(cathy); //safariList.Add(phil); //foreach (var item in safariList) //{ // Console.WriteLine(item); //} //Airplane a = new Airplane(200, 100, "JetsRUs") //{ NumPassengers = 150 }; //a.Ascend(500); //Console.WriteLine(a.Move(3)); //Console.WriteLine(a); //a.Descend(200); //Console.WriteLine(a.Move()); //a.Move(); //Console.WriteLine(a); //List<Object> gameObjects = new List<Object>() // { // new Person("Cathy", "French"), // new Airplane(400,200,"Booing"), // new Vehicle(12, 20), // new Hunter("Henry", "Hodgkins", "Pentax") // }; //foreach (var gameObj in gameObjects) //{ // Console.WriteLine(gameObj); //} //var yolanda = new Person("Yolanda", "Young"); //SpartaWrite(yolanda); ////var nish = new Hunter("Nish", "Mandal", "Leica"); ////SpartaWrite(nish); //static void SpartaWrite(Object obj) //{ // Console.WriteLine(obj.ToString()); // var hunterObj = (Hunter)obj; // Console.WriteLine(hunterObj.Shoot()); //} //var cathy = new Person("Cathy", "French"); //var booing = new Airplane(400, 200, "Booing"); //var vehicle = new Vehicle(12, 20); //var henry = new Hunter("Henry", "Hodgkins", "Pentax"); //List<IMovable> gameObjects = new List<IMovable>() // { // cathy, // booing, // vehicle, // henry // }; //foreach (var item in gameObjects) //{ // Console.WriteLine(item.Move()); //} //var theWeapons = new List<IShootable>(); //theWeapons.Add(new WaterPistol("ToysRUs")); //theWeapons.Add(new LaserGun("Acme")); //theWeapons.Add(new Hunter("Cathy", "French", new Camera("Minolta"))); //theWeapons.Add(new Camera("Pentax")); //foreach (var w in theWeapons) //{ // Console.WriteLine(w.Shoot()); //} Console.WriteLine(); Console.WriteLine("Polymorphic shootout"); Camera pentax = new Camera("Pentax"); WaterPistol pistol = new WaterPistol("Supersoaker"); LaserGun laserGun = new LaserGun("Acme"); Hunter nish = new Hunter("Nish", "Mandal", pentax); Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); nish.Shooter = laserGun; Console.WriteLine(nish.Shoot()); nish.Shooter = pistol; Console.WriteLine(nish.Shoot()); Hunter phil = new Hunter("Phil", "Anderson"); Console.WriteLine(phil.Shoot()); }
static void Main(string[] args) { {//Person cathy = new Person("Cathy", "French"); //Console.WriteLine(cathy.GetFullName()); //cathy.Age = -1; //Console.WriteLine("Cath's Age:s " + cathy.Age); //cathy.Age = 26; //Console.WriteLine("Cath's Age:s " + cathy.Age); //Person nish; // declaring nish before they're constructed. value will be null //nish = new Person("Nish", "Mandal"); //Console.WriteLine(nish.GetFullName()); ////var sparta = new Spartan("Nish", "Mandal", 30); //var spartan = new Spartan { FirstName = "Nish", LastName = "Mandal Age = 30" }; //var age = spartan.Age; //var rouz = new Person(); //var callum = new Person("Callum", "Harding"); //var michael = new Person("Michael", "Wilcock", 22); //var hamse = new Person("Hamse", "Ahmed") { Age = 21 }; //var shopList = new ShoppingList { Bread = 2, Milk = 10, Potato = 1 }; //// Structs //Point3d p; //Person paul = new Person("Paul", "Mcartney") { Age = 80 }; //Point3d pt3d = new Point3d(5, 8, 2); //DemoMethod(pt3d, paul); ///*Hunter h = new Hunter("Hossain", "Ghazal", "Leica") { Age = 22 };*/ //Console.WriteLine(h.Age); //Console.WriteLine(h.Shoot()); //Hunter h = new Hunter("Hossain", "Ghazal", "Leica") { Age = 22 }; //Hunter h2 = new Hunter("Hossain", "Ghazal", "Leica") { Age = 22 }; //Console.WriteLine($"{h} Equals {h2}? {h.Equals(h2)}"); //Console.WriteLine($"{h} HashCode: {h.GetHashCode()}"); //Console.WriteLine($"{h} ToString(): {h.ToString()}"); //Console.WriteLine(h); //var rectangle1 = new Rectangle { Width = 10, Height = 10 }; //var rectangle2 = new Rectangle { Width = 15, Height = 10 }; //var shapeList = new List<Shape> { rectangle1, rectangle2 }; //var totalArea = 0; //shapeList.ForEach(x => totalArea += x.CalculateArea()); //Console.WriteLine(totalArea); //Airplane a = new Airplane(200, 100, "JetsRUs") { NumPassengers = 150 }; //a.Ascend(500); //Console.WriteLine(a.Move(3)); //Console.WriteLine(a); //a.Descend(200); //Console.WriteLine(a.Move()); //a.Move(); //Console.WriteLine(a); //var gameObjects = new List<Object>() //{ // new Person ("Nish", "Mandal"), // new Airplane (400, 200, "Virgin"), // new Vehicle (12, 20), // new Hunter ("Tim", "Burton", "Nikon") //}; //gameObjects.ForEach(x => Console.WriteLine(x)); //var liam = new Person("Liam", "Gallagher"); //SpartaWrite(liam); //var billoddie = new Hunter("Bill", "Oddie", "Nokia"); //SpartaWrite(billoddie); //SpartaWrite((Person)billoddie); //// IMoveable Implementation //var movableObjects = new List<IMoveable>() //{ // new Person("John", "Smith") // , new Hunter("Bill", "Oddie", "Nikon") // , new Airplane (400, 200, "Virgin") // , new Vehicle (12, 20), //}; //movableObjects.ForEach(x => Console.WriteLine(x.Move())); //// <Weapon>/<IShootable> demonstration //var weaponList = new List<IShootable>() //{ // new WaterPistol("Nerf Super Soaker Zipfire") // , new LaserGun("General Atomics AER9") // , new Hunter("John", "Wayne", new Camera("Nikon") ) // , new Hunter("Richard", "Deckard", new Camera("Pentax") ) // , new Camera("Fujifilm") //}; //weaponList.ForEach(x => Console.WriteLine(x.Shoot())); } //When you shoot the distance between yourself and the creature along with the volume of the item decide whether it startles or not. //If it's startled check if it's charging or bolting //If it's chargin it moves towards you, if it's bolting it runs away. Once it's X distance from you it has a chance to escape. // You can either move/fire/switch device. // Weapons var weaponList = new List <IShootable>() { new WaterPistol("Nerf Super Soaker Zipfire", 10) , new LaserGun("General Atomics AER9", 6) , new Camera("Fujifilm", 1) }; // animal list var animalList = new List <Animal> { new Gazelle(60) , new Bufallo(60) }; Random rnd = new Random(); int randAnimal = rnd.Next(0, 1); Console.WriteLine("What is your first name ?"); string fName = Console.ReadLine(); Console.WriteLine("What is your last name ?"); string lName = Console.ReadLine(); Hunter player = new Hunter(fName, lName, weaponList[0]); bool gameOn = true; while (gameOn) { string command; Console.WriteLine($"Would you like to 1. Move, 2. Shoot, 3. Change tool ? 4. Exit game"); command = Console.ReadLine(); switch (command) { case "1": //Console.WriteLine(player.Move()); Console.WriteLine("Not yet implemented"); break; case "2": Console.WriteLine(player.Shoot()); Console.WriteLine(animalList[randAnimal].FightOrFlight(player.Shooter.Volume)); break; case "3": weaponList.ForEach(x => Console.WriteLine(x.ToString())); int weapon = int.Parse(Console.ReadLine()); player.Shooter = weaponList[weapon - 1]; break; case "4": Console.WriteLine("Are you sure ? (Y/N)"); string exit = Console.ReadLine(); gameOn = exit == "Y" ? false : true; break; default: Console.WriteLine("Not a valid command"); break; } // if gazelle is further than 100 away it has a chance to flee if (animalList[randAnimal].Position > 100) { Console.WriteLine($"{animalList[randAnimal].ToString()} has escaped!"); Console.WriteLine("Game over"); gameOn = false; } } }
static void Main(string[] args) { //Person cathy = new Person("Cathy", "French"); //Console.WriteLine(cathy.GetFullName()); //cathy.Age = -1; //Console.WriteLine("Cathy's Age: " + cathy.Age); //cathy.Age = 26; //Console.WriteLine("Cathy's Age: " + cathy.Age); //cathy.Age = -1; //Console.WriteLine("Cathy's Age: " + cathy.Age); //Person nish; //nish = new Person("Nish", "Mandal"); //Console.WriteLine(nish.GetFullName()); //var spartan = new Spartan {FirstName = "Nish", LastName = "Mandal", Age = 30 }; //var age = spartan.Age; //var rouz = new Person(); //rouz.Age = 22; //var callum = new Person("Callum", "Harding"); //var michael = new Person("Michael", "Willcock", 22); //var hamse = new Person("Hamse", "Ahmed") { Age = 21 }; //var shopList = new ShoppingList() { Bread = 2, Potato = 9 }; //shopList.Potato = 7; //var shopList2 = new ShoppingList { Soap = 2 }; // Point3d p; //Person paul = new Person("Paul", "McCartney") { Age = 80 }; //Point3d pt3d = new Point3d(5, 8, 2); //DemoMethod(pt3d, paul); //Hunter h = new Hunter("Hossain", "Ghazal", "Leica") { Age = 22 }; //Hunter h2 = new Hunter("Hossain", "Ghazal", "Leica") { Age = 22 }; //Console.WriteLine($"{h} Equals {h2}? {h.Equals(h2)}"); //Console.WriteLine($"{h} Hascode {h.GetHashCode()}"); //Console.WriteLine($"{h} ToString"); //Console.WriteLine(h.Age); //Console.WriteLine(h.Shoot()); //var rectangle1 = new Rectangle { Width = 10, Height = 10 }; //var rectangle2 = new Rectangle { Width = 15, Height = 10 }; //var totalArea = 0; //var shapeList = new List<Shape> { rectangle1, rectangle2 }; //foreach (var x in shapeList) //{ // totalArea = x.CalculateArea(); //} //Airplane a = new Airplane(200, 100, "JetRUs") { NumPassengers = 150 }; //a.Ascend(500); //Console.WriteLine(a.Move(3)); //Console.WriteLine(a); //a.Descend(200); //Console.WriteLine(a.Move()); //a.Move(); //Console.WriteLine(a); //var gameObject = new List<Object>() //{ // new Person ("Nish", "Mandal"), // new Airplane (400, 200, "Virgin Flights"), // new Hunter("Tim", "Burton", "Nikon") //}; //gameObject.ForEach(x => Console.WriteLine(x)); //var liam = new Person("Liam", "Gallagher"); //SpartaWrite(liam); //var cathy = new Person("Cathy", "French"); //var nish = new Hunter("Nish", "Mandal", "Pentax"); //var nishPerson = (Person)nish; //var cathyHunter = (Hunter)cathy; //SpartaWrite(nish); //Console.WriteLine(); //SpartaWrite(cathy); //var safariObject = new List<IMoveable>() //{ // new Person("Michael", "Willcock"), // new Person("Uzair", "Khan"), // new Person("Hossain", "Ghazal") //}; //safariObject.ForEach(x => Console.WriteLine(x.Move())); //var weaponObj = new List<IShootable>() //{ // new Hunter("Nish", "Mandal", new Camera("Pentax")), // new Hunter("Nish", "Mandal", new WaterPistol("Supersoaker")), // new Hunter("Nish", "Mandal", new LaserGun("Acme")), // new Hunter("Nish", "Mandal", new WaterPistol("Supersoaker")), // new Hunter("Michael", "Willcock", new Rifle("Springfield",".15 cartridges", 50)) //}; //weaponObj.ForEach(x => Console.WriteLine(x.Shoot())); var photographer = new Hunter("Geoff", "Bridges", new Camera("Kodak")); var springfieldRifle = new Rifle("Springfield", ".15 cartridges"); var superSoaker = new WaterPistol("Supersoaker", "ml of water", 1000); var spartanLaser = new LaserGun("Spartan Laser", "kJ", 5000); var rifleShoot = new Hunter("Michael", "Willcock", springfieldRifle); var laserBlast = new Hunter("Master", "Chief", spartanLaser); Console.WriteLine(photographer.Shoot()); Console.WriteLine(rifleShoot.Shoot()); springfieldRifle.Fire(7); Console.WriteLine(rifleShoot.Shoot()); Console.WriteLine(superSoaker.Shoot()); superSoaker.Fire(10); Console.WriteLine(superSoaker.Shoot()); superSoaker.Fire(1000); Console.WriteLine(superSoaker.Shoot()); Console.WriteLine(laserBlast.Shoot()); spartanLaser.Fire(50); Console.WriteLine(laserBlast.Shoot()); spartanLaser.Fire(5000); Console.WriteLine(laserBlast.Shoot()); }
static void Main() { Person Uzair = new Person("Uzair", "Khan", 23); Uzair.GetFullName(); Person Bob = new Person("Bob", "Dugless") { Age = 34 }; Uzair.GetFullName(); ShoppingList sl = new ShoppingList() { Potatoes = 1, Dragonfruit = 2 }; sl.Eggplant = 6; Point3D pt = new Point3D(); Person paul = new Person("Paul", "Loft", 50); DemoMethod(pt, paul); Camera camera = new Camera("Canon MX545"); Hunter h = new Hunter("Harry", "Smith", camera) { Age = 29 }; System.Console.WriteLine(h.Shoot()); Hunter h2 = new Hunter() { }; //System.Console.WriteLine(h2.Shoot()); System.Console.WriteLine(h.ToString()); Rectangle r1 = new Rectangle() { Width = 10, Height = 15 }; Rectangle r2 = new Rectangle() { Width = 43, Height = 34 }; int totalArea = 0; var rectangleList = new List <IShape>() { r1, r2 }; rectangleList.ForEach(x => totalArea += x.CalculateArea()); System.Console.WriteLine(totalArea); var gameObject = new List <object>() { new Person("Nish", "Man"), new Hunter(), new Vehicle(), new Airplane(100) }; gameObject.ForEach(x => System.Console.WriteLine(x)); var person = new Person("Per", "Son"); var hunter = new Hunter("Hun", "Ter", camera); SpartanName(person); SpartanName(hunter); var hunterToPerson = (Person)hunter; //var personToHunter = (Hunter)person; //Throw an error because you can't var movingObjects = new List <IMoveable>() { new Person(), new Vehicle(), new Hunter(), new Airplane(100) }; movingObjects.ForEach(x => System.Console.WriteLine(x.Move())); movingObjects.ForEach(x => System.Console.WriteLine(x.Move(3))); var weapons = new List <IShootable>(); weapons.Add(new LaserGun("MD453")); weapons.Add(new WaterPistol("Nerf")); weapons.Add(new LaserGun("ATX-8D-0B")); weapons.Add(new WaterPistol("#1")); weapons.Add(new LaserGun("KLR/RT6")); weapons.Add(new WaterPistol("Super Soaker")); weapons.Add(new LaserGun("G6:H7")); weapons.Add(new WaterPistol("Water Powered")); weapons.Add(new Hunter("Bod", "Dugless", weapons[1])); weapons.Add(new Hunter("Sally", "Sue", weapons[3])); weapons.Add(new Hunter("Git", "Hub", new Camera("Canon MX545"))); weapons.ForEach(x => System.Console.WriteLine(x.Shoot())); }