repl.it
@kironroy/

guestlist

C#

No description

fork
loading
Files
  • main.cs
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Globalization;


// Ask for the user's name
// Add the name to the list of names
// Ask for the user's party count
// Add the party count to the total party number
// print out all names
// print out total party number

namespace ConsoleUI
{
    class Program
    {

        private static List<string> parties = new List<string>();
        private static int totalGuests = 0;


        static void Main(string[] args)
        {


            LoadGuests();

            DislpayGuests();

            DisplayGuestCount();

            Console.WriteLine();
        
            Console.ReadLine();

         
        }

          
        private static void DisplayGuestCount()
        {
            Console.WriteLine($"Total guests: {totalGuests} ");
        }

        private static void DislpayGuests()
        {
            Console.WriteLine();
            Console.WriteLine("Guest Parties at Event: ");
            Console.WriteLine();

            Console.WriteLine("--------------------------");

            foreach (string name in parties)
            {
                Console.WriteLine(name);
            }

            Console.WriteLine();
            Console.WriteLine("--------------------------");
        }

        private static void LoadGuests()
        {
            string moreGuestscoming = "";

            do
            {
                string partyName = GetInfoFromConsole("What is your party/group name: ");
                string partyNameCaps = new CultureInfo("en-US").TextInfo.ToTitleCase(partyName);

                parties.Add(partyNameCaps);

                totalGuests += GetPartySize();

                DisplayGuestCount();

                moreGuestscoming = GetInfoFromConsole("Do you want to add another guest (yes/no): ");
            } while (moreGuestscoming.ToLower() == "yes");
        }

        private static int GetPartySize()
        {
            bool isValidNumber = false;
            int output = 0;

            do
            {
                string partySizeText = GetInfoFromConsole("How many people are in your party: ");

                isValidNumber = int.TryParse(partySizeText, out output);

            } while (isValidNumber == false);

            return output;

        }

        private static string GetInfoFromConsole(string message)
        {
            Console.WriteLine(message);
            string output = Console.ReadLine();

            return output;
        }


    }
}