public void AddFisher(string name, string phone) { Fisherman fisher = new Fisherman(name); fisher.PhoneNumber = phone; AddFisher(fisher); }
static void Main(string[] args) { // ready the database FishRegistry fishers = new FishRegistry(); // add fisher fishers.AddFisher("Kirsi Kernel", "020-12345678"); // see if we can find it again Fisherman kirsi = fishers.FindFisher("Kirsi Kernel"); // catch some fish FishingSpot jyvaskyla = new FishingSpot("The Lake of Jyväskylä", "Jyväskylä"); kirsi.Catch(new Fish("pike", 120, 4.5, jyvaskyla, kirsi)); kirsi.Catch(new Fish("salmon", 190, 13.2, new FishingSpot("River Teno", "The Northern edge of Finland"), kirsi)); // let's get a second fisherman and give him a fish { Fisherman uolevi = new Fisherman("Uolevi Kärppä"); uolevi.Catch(new Fish("crucian carp", 20, 0.4, jyvaskyla, uolevi)); fishers.AddFisher(uolevi); } // list all fish Console.WriteLine(); fishers.PrintAllFish(); // and sort them by weight Console.WriteLine(); fishers.PrintAllFishByWeight(); }
public Fish(string species, double length, double weight, FishingSpot place, Fisherman caughtBy) { this.Species = species; this.Length = length; this.Weight = weight; this.CaughtAt = place; this.CaughtBy = caughtBy; }
public void AddFisher(Fisherman fisher) { FisherList.Add(fisher); Console.WriteLine("New fisherman added: " + fisher.Name + ", Phone: " + fisher.PhoneNumber); }