Esempio n. 1
0
        static void Main(string[] args)
        {
            MemberList ml = new MemberList();
            ml.FetchData("members.bin");

            while (true)
            {
                Console.Write("C to create, R to read, D to delete: ");

                char choice = Console.ReadKey().KeyChar;
                Console.WriteLine("");

                if (choice == 'c')
                {

                    Console.Write("Name: ");
                    string name = Console.ReadLine();
                    Console.Write("SSN: ");
                    string ssn = Console.ReadLine();
                    var m = new Member(name, ssn);

                    Console.WriteLine("Enter boat names (enter no name to finalize):");

                    string boatname = "";
                    boatname = Console.ReadLine();
                    while (boatname.Trim() != "")
                    {
                        Boat b = new Boat(boatname);
                        m.AddBoat(b);
                        boatname = Console.ReadLine();
                    }

                    ml.Add(m);
                    Console.Clear();

                }
                else if (choice == 'r')
                {
                    Console.Clear();
                    ml.List();
                }
                else if (choice == 'd')
                {
                    Console.Clear();
                    Console.WriteLine("Select member to kill:");
                    ml.List();
                    int id = 0;
                    if (int.TryParse(Console.ReadLine(),out id))
                    {
                        if (id<ml.members.Count && id >= 0)
                        {
                            ml.members.RemoveAt(id);
                            Console.Clear();
                            Console.WriteLine("He's dead, Jim");
                        }
                        else
                        {
                            Console.BackgroundColor = ConsoleColor.Red;
                            Console.WriteLine("Not in there, BRAH.");
                            Console.BackgroundColor = ConsoleColor.Black;
                        }
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.WriteLine("Not a number bro.");
                        Console.BackgroundColor = ConsoleColor.Black;
                    }
                }
                else
                {
                    ml.SaveToFile("members.bin");
                    break;
                }
            }
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     XmlSerializer xs      = new XmlSerializer(typeof(MemberList));
     XmlTextReader reader  = new XmlTextReader(FILENAME);
     MemberList    members = (MemberList)xs.Deserialize(reader);
 }