Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Outing Golf    = new Outing("Golf", 5, DateTime.Parse("7/12/18"), 20.00, 100.00);
            Outing Bowling = new Outing("Bowling", 5, DateTime.Parse("6/12/18"), 20.00, 100.00);
            Outing Park    = new Outing("Park", 5, DateTime.Parse("5/12/18"), 20.00, 100.00);
            Outing Concert = new Outing("Concert", 5, DateTime.Parse("4/12/18"), 20.00, 100.00);

            Outing_Repository outingRepo = new Outing_Repository();

            outingRepo.addOutingToTheList(Golf);
            outingRepo.addOutingToTheList(Bowling);
            outingRepo.addOutingToTheList(Park);
            outingRepo.addOutingToTheList(Concert);

            List <Outing> outingList = outingRepo.showListOfOuting();
            string        response   = "null";

            while (response != "4")
            {
                outingRepo.showMenu();
                Console.WriteLine("Choose a item number listed above.");
                int    reply2       = int.Parse(Console.ReadLine());
                double golfTotal    = 0;
                double bowlingTotal = 0;
                double parkTotal    = 0;
                double concertTotal = 0;

                if (reply2 == 1)
                {
                    Console.Clear();
                    Console.WriteLine("Event\t" + "PeopleAttended\t" + "Date\t" + "Cost per person\t" + "Cost per Event");
                    foreach (Outing outing in outingList)
                    {
                        Console.WriteLine($"{outing.EventType}\t" + $"{outing.NumberOfPeopleAttended}\t" + $"{outing.Date}\t" + $"{outing.CostPerPerson}\t" + $"{outing.CostPerEvent}");
                    }
                }
                else if (reply2 == 2)
                {
                    Console.Clear();
                    Console.Write("Enter the event type: ");
                    string eventType = Console.ReadLine();
                    Console.Write("Number of people that attended: ");
                    int attended = int.Parse(Console.ReadLine());
                    Console.Write("Date: ");
                    DateTime date = DateTime.Parse(Console.ReadLine());
                    Console.Write("Total cost per person for the event: ");
                    double costPerPerson = double.Parse(Console.ReadLine());
                    Console.Write("Total cost for the event: ");
                    double costForTheEvent = double.Parse(Console.ReadLine());
                    Outing outingObject    = new Outing(eventType, attended, date, costPerPerson, costForTheEvent);
                    outingRepo.addOutingToTheList(outingObject);
                    foreach (Outing item in outingList)
                    {
                        Console.WriteLine($"{item.EventType}\t" + $"{item.NumberOfPeopleAttended}\t" + $"{item.Date}\t" + $"{item.CostPerPerson}\t" + $"{item.CostPerEvent}");
                    }
                }
                else if (reply2 == 3)
                {
                    foreach (Outing item in outingList)
                    {
                        if (item.EventType == "Golf")
                        {
                            golfTotal = golfTotal + item.CostPerEvent;
                        }
                        else if (item.EventType == "Bowling")
                        {
                            bowlingTotal = bowlingTotal + item.CostPerEvent;
                        }
                        else if (item.EventType == "Park")
                        {
                            parkTotal = parkTotal + item.CostPerEvent;
                        }
                        else if (item.EventType == "Concert")
                        {
                            concertTotal = concertTotal + item.CostPerEvent;
                        }
                    }
                    double total = golfTotal + bowlingTotal + parkTotal + concertTotal;
                    Console.WriteLine("Total of all events: " + total + " , " + "Total of Golf: " + golfTotal + " , " + "Total of Bowling: " + bowlingTotal + " , " + "Total of park: " + parkTotal + " , " + "Total of concert: " + concertTotal);
                }
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            int              golfOuting      = 0;
            int              bowlOuting      = 0;
            int              amusementOuting = 0;
            int              concertOuting   = 0;
            Outing           outing          = new Outing();
            OutingRepository repo            = new OutingRepository();

            Console.WriteLine("Komodo outings calculator. Please select from the following options: \n" +
                              "1. List all outings \n" +
                              "2. Add an outing to a list \n" +
                              "3. See total amount for all outings \n" +
                              "4. See amount for each outing by type");

            string choice = Console.ReadLine();

            switch (choice)
            {
            case "1":
                repo.DisplayAllOutings();
                break;

            case "2":
                Console.WriteLine("What kind of event are you adding? \n" +
                                  "1. Golf \n" +
                                  "2. Bowling \n" +
                                  "3. Amusement Park \n" +
                                  "4. Concert");
                string eventChoice = Console.ReadLine();
                switch (eventChoice)
                {
                case "1":
                    golfOuting++;
                    repo.AddNewOuting();
                    break;

                case "2":
                    bowlOuting++;
                    repo.AddNewOuting();
                    break;

                case "3":
                    amusementOuting++;
                    repo.AddNewOuting();
                    break;

                case "4":
                    concertOuting++;
                    repo.AddNewOuting();
                    break;

                default:
                    Console.WriteLine("Invalid choice. Returning to main menu.");
                    Console.ReadLine();
                    Run();
                    break;
                }
                break;

            case "3":
                repo.AddAllOutings();
                break;

            case "4":
                Console.WriteLine("Which outing do you want to see the total for? \n" +
                                  "1. Golf \n" +
                                  "2. Bowling \n" +
                                  "3. Amusement Park \n" +
                                  "4. Concert");
                string totalChoice = Console.ReadLine();
                switch (totalChoice)
                {
                case "1":
                    int golf = (int)Outing.TypeOfOuting.Golf;
                    repo.CalculateEachOuting(golf);
                    break;

                case "2":
                    int bowling = (int)Outing.TypeOfOuting.Bowling;
                    repo.CalculateEachOuting(bowling);
                    break;

                case "3":
                    int amusement = (int)Outing.TypeOfOuting.AmusementPark;
                    repo.CalculateEachOuting(amusement);
                    break;

                case "4":
                    int concert = (int)Outing.TypeOfOuting.Concert;
                    repo.CalculateEachOuting(concert);
                    break;

                default:
                    break;
                }
                break;

            default:
                Console.WriteLine("Invalid choice. Returning to main menu.");
                Console.ReadLine();
                Run();
                break;
            }
        }