1 //created by Heather Travar on 4/1/14
2 //This program asks user who in their family is most likely to survive a zombie
3 //apocalypse and displays the results
4 //also get code here: https://github.com/htravar/Zombie
5 using System;
6
7 class Zombie
8 {
9 public string Relations {get; set;}//auto implemented properties
10 public string RelativeName {get; set;}
11
12 public Zombie(string name, string relationship)
13 {
14 RelativeName = name;
15 Relations = relationship;
16 }
17
18 public void DisplayInfo()
19 {
20 Console.WriteLine("The relative you feel most likely\nto survive a zombie");
21 Console.WriteLine ("apocalypse is {0}, your{1}.", RelativeName, Relations);
22 }
23 }//end class Zombie
24
25 class ZombieTest
26 {
27 static void Main(string[] args)
28 {
29 string nameOfRelative;
30 Console.WriteLine("Will anyone in your family survive the zombie apocalypse?");
31 Console.WriteLine("Enter the name of the one MOST likely to survive.");
32 nameOfRelative = Console.ReadLine();
33
34 Console.WriteLine();
35
36 string relationtoRelative;
37 Console.WriteLine("Enter this person's relationship to this you.");
38 relationtoRelative = Console.ReadLine();
39
40 Console.WriteLine();
41
42 Zombie survivor = new Zombie(nameOfRelative, relationtoRelative);
43 survivor.DisplayInfo();
44
45 Console.ReadKey();
46
47 }//end Main method
48 }//end class ZombieTest
No comments:
Post a Comment