コード例 #1
0
ファイル: Program.cs プロジェクト: terankeith/ProjectsForFun
        static void Main(string[] args)
        {
            TeamOps TeamOps = new TeamOps();
            YearOps YearOps = new YearOps();
            VenueOps VenueOps = new VenueOps();
            ChampionshipOps ChampOps = new ChampionshipOps();

            Console.WriteLine("1. Display a Team");
            Console.WriteLine("\n2. Add a Team");
            Console.WriteLine("\n3. Add a Year");
            Console.WriteLine("\n4. Add a Venue");
            Console.WriteLine("\n5. Add a Championship");
            Console.WriteLine("\n6. Delete a Team");
            string choice = Console.ReadLine();
            switch (choice)
            {
                case "1":
                    Console.Clear();
                    TeamOps.DisplayTeams();
                    Console.WriteLine("Type the name of the team you would like to see more information about.");
                    string input = Console.ReadLine();
                    Team displayTeam = TeamOps.GetTeamByName(input);
                    Console.Clear();
                    Console.WriteLine("Team Name: {0}", displayTeam.Name);
                    Console.WriteLine("Sport: {0}", displayTeam.Sport);
                    Console.WriteLine("Mascot: {0}", displayTeam.Mascot);
                    Console.WriteLine("Coach: {0}", displayTeam.Coach);
                    Console.WriteLine("Owner: {0}", displayTeam.Owner);
                    Console.WriteLine("Average Salary: {0}", displayTeam.AvgSalary);
                    Console.WriteLine("Activity Status: {0}", displayTeam.Active);
                    Console.WriteLine("Number of Convictions: {0}", displayTeam.Convictions);
                    Console.ReadLine();
                    break;
                case "2":
                    Team newTeam = TeamOps.CreateTeam();
                    TeamOps.AddTeam(newTeam);
                    break;
                case "3":
                    Year newYear = YearOps.CreateYear();
                    YearOps.AddYear(newYear);
                    break;
                case "4":
                    Venue newVenue = VenueOps.CreateVenue();
                    VenueOps.AddVenue(newVenue);
                    break;
                case "5":
                    Championship newChamp = ChampOps.CreateChamp();
                    ChampOps.AddChamp(newChamp);
                    break;
                case "6":
                    Console.Clear();
                    TeamOps.DisplayTeams();
                    Console.Write("\nEnter the name of the team you would like to delete: ");
                    string teamName = Console.ReadLine();
                    TeamOps.DeleteTeamByName(teamName);
                    break;
                default:
                    break;
            }
        }
コード例 #2
0
ファイル: TeamOps.cs プロジェクト: terankeith/ProjectsForFun
        public Team CreateTeam()
        {
            Team newTeam = new Team();
            int Id;
            bool isValid = false;
            Console.Clear();
            bool isActive = false;
            Console.Write("Enter the name of the team: ");
            string name = Console.ReadLine();
            Console.Write("\nSport: ");
            string sport = Console.ReadLine();
            Console.Write("\nMascot: ");
            string mascot = Console.ReadLine();
            Console.Write("\nCoach: ");
            string coach = Console.ReadLine();
            Console.Write("\nOwner: ");
            string owner = Console.ReadLine();
            Console.Write("\nAverage Salary: ");
            decimal salary = decimal.Parse(Console.ReadLine());
            Console.Write("\nIs the team still active(Y/N): ");
            string active = Console.ReadLine();
            if (active.ToUpper() == "Y")
            {
                isActive = true;
            }
            else
            {
                isActive = false;
            }
            Console.Write("\nNumber of Convictions: ");
            int convictions = int.Parse(Console.ReadLine());

            VenueOps ops = new VenueOps();
            do {
                Console.Clear();
                ops.DisplayVenues();
                Console.Write("Enter the number that corresponds with the Venue Building.\nIf you do not know the building name press enter.\nIf you do know the name of the building, type 'Building'");
                string venue = Console.ReadLine();
                if (int.TryParse(venue, out Id))
                {
                    newTeam.VenueId = Id;
                    isValid = true;
                }
                else if (venue == "")
                {
                    newTeam.VenueId = null;
                    isValid = true;
                }
                else if (venue.ToUpper() == "BUILDING")
                {
                    Venue created = ops.CreateVenue();
                    ops.AddVenue(created);
                    isValid = false;
                }
                else
                {
                    isValid = false;
                }
            } while (!isValid);

            newTeam.Name = name;
            newTeam.Sport = sport;
            newTeam.Mascot = mascot;
            newTeam.Coach = coach;
            newTeam.Owner = owner;
            newTeam.AvgSalary = salary;
            newTeam.Active = isActive;
            newTeam.Convictions = convictions;

            return newTeam;
        }