//For assignment 1, see Person.CS static void Main(string[] args) { #region Assignment4 Person person = new Person(); // person.age = 7; SVAR: Nej, ger error person.age is inaccessible #endregion //For assignment 5, see PersonHandler.cs #region Assignment10 PersonHandler PH = new PersonHandler(); Person Evert = PH.CreatePerson(21, "Evert", "Taub", 175, 100); Person Eva = PH.CreatePerson(40, "Eva", "Lindgren", 168, 70); Console.WriteLine(Evert.FName + " " + Evert.LName + " is " + Evert.Age + " years old"); Console.WriteLine(Eva.FName + " " + Eva.LName + " is " + Eva.Age + " years old"); Console.WriteLine("Evert marries eva, evas name is now:"); PH.GetMarried(Evert, Eva, true); Console.WriteLine(Eva.FName + " " + Eva.LName); PH.Birthday(Evert); PH.Birthday(Eva); Console.WriteLine("A year passes and they are now: " + Evert.Age + " and " + Eva.Age); Console.WriteLine("Eva earlier weighed " + Eva.Weight + "kg but has during this year lost 10kg"); PH.LoseWeight(Eva, 10); Console.WriteLine("Now she weighs " + Eva.Weight); Console.ReadKey(); #endregion }
public void GetMarried(Person nameGiver, Person nameTaker, bool doubleName) { if (!doubleName) { nameTaker.LName = nameGiver.LName; } else { nameTaker.LName += " " + nameGiver.LName; } }
public Person CreatePerson(int age, string fName, string lName, double height, double weight) { Person temporaryPerson = new Person(); temporaryPerson.Age = age; temporaryPerson.FName = fName; temporaryPerson.LName = lName; temporaryPerson.Height = height; temporaryPerson.Weight = weight; return temporaryPerson; }
public void SetAge(Person person, int age) { #region Assignment7 person.Age = age; #endregion }
public void NameChange(Person person, string newfName, string newlName) { person.FName = newfName; person.LName = newlName; }
public void LoseWeight(Person person, int weightloss) { person.Weight -= weightloss; }
//The following methods are examples for what you could want. Not required. public void Birthday(Person person) { person.Age += 1; }