Ejemplo n.º 1
0
 private void addPerson()
 {
     Person ps = new Person();
     Console.WriteLine("Write the ID");
     try
     {
         ps.Id = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine("Write the name");
         ps.Name = Console.ReadLine();
         Console.WriteLine("Write the age");
         ps.Age = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine("Write the height");
         ps.Height = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine("Write the weight");
         ps.Weight = Convert.ToInt32(Console.ReadLine());
         Console.Clear();
     }
     catch (Exception)
     {
         Console.Clear();
         Console.WriteLine("Wrong input returned to start menu");
         startMenu();
     }
     persons.Add(ps);
 }
Ejemplo n.º 2
0
        public void personInstances()
        {
            Person personA = new Person();
            try
            {
                Console.WriteLine("**** Person ****");
                Console.WriteLine("Skriv id: ");
                personA.id = int.Parse(Console.ReadLine());

                Console.WriteLine("Skriv navn: ");
                personA.name = Console.ReadLine();

                Console.WriteLine("Skriv Alder: ");
                personA.age = int.Parse(Console.ReadLine());

                Console.WriteLine("Skriv højde: ");
                personA.height = int.Parse(Console.ReadLine());

                Console.WriteLine("Skriv vægt: ");
                personA.weight = int.Parse(Console.ReadLine());

                personA.carList = new List<Cars>();
                personList.Add(personA);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }