Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Text;
- using System.Collections.Generic;
- namespace TouristAgency
- {
- class Client
- {
- private string name;
- private string surename;
- private int age;
- private string destination;
- private int frontDeskNumber;
- public string Name { get { return name; } set { name = value; } }
- public string Surename { get { return surename; } set { surename = value; } }
- public int Age { get { return age; } set { age = value; } }
- public string Destination { get { return destination; } set { destination = value; } }
- public int FrontDeskNumber { get { return frontDeskNumber; } set { frontDeskNumber = value; } }
- public Client(string name, string surename, int age, string destination, int frontDeskNumber)
- {
- this.name = name;
- this.surename = surename;
- this.age = age;
- this.destination = destination;
- this.frontDeskNumber = frontDeskNumber;
- }
- public int getPrice()
- {
- return destination.Length * 2000;
- }
- }
- class FrontDesk
- {
- private int number;
- public List<Client> deskClients;
- public int Number { get { return number; } set { number = value; } }
- public FrontDesk(int number)
- {
- this.number = number;
- deskClients = new List<Client>();
- }
- public void addClient(Client client)
- {
- deskClients.Add(client);
- }
- public int GetClientLength()
- {
- return deskClients.Count;
- }
- public int calculatePrice()
- {
- int suma = 0;
- foreach (Client c in deskClients)
- {
- suma += c.getPrice();
- }
- return suma;
- }
- public string toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("Salter ").Append(number+" :").Append("\n");
- sb.Append(GetClientLength()).Append(" karti").Append("\n");
- return sb.ToString();
- }
- }
- class TouristAgency
- {
- private string name;
- private int numberOfDesks;
- List<Client> clients;
- List<FrontDesk> frontDesks;
- List<String> destinations;
- public TouristAgency(string name, int numberOfDesks)
- {
- this.name = name;
- this.numberOfDesks = numberOfDesks;
- clients = new List<Client>();
- frontDesks = new List<FrontDesk>(numberOfDesks);
- destinations = new List<string>();
- createDestinations();
- }
- public void createDestinations()
- {
- destinations.Add("Rim");
- destinations.Add("London");
- destinations.Add("Tokio");
- destinations.Add("Sofija");
- destinations.Add("Istanbul");
- destinations.Add("Toronto");
- destinations.Add("Majami");
- destinations.Add("Zagreb");
- destinations.Add("Belgrad");
- destinations.Add("Moskva");
- }
- public void ClientService(Client client)
- {
- clients.Add(client);
- if (destinations.Contains(client.Destination))
- {
- if (CheckForDesks(client) == true)
- {
- FrontDesk fd = CheckIfDeskExists(client.FrontDeskNumber);
- if (fd == null)
- {
- fd = new FrontDesk(client.FrontDeskNumber);
- fd.addClient(client);
- frontDesks.Add(fd);
- }
- else
- {
- fd.addClient(client);
- }
- }
- }
- }
- public void GetNumberOfClients(int frontDeskNumber)
- {
- FrontDesk fd = CheckIfDeskExists(frontDeskNumber);
- if(fd!=null)
- Console.Write(fd.GetClientLength());
- }
- public void GetPriceFromDesk(int frontDeskNumber)
- {
- FrontDesk fd = CheckIfDeskExists(frontDeskNumber);
- if (fd != null)
- Console.Write(fd.calculatePrice());
- }
- public string toString()
- {
- StringBuilder sb = new StringBuilder();
- foreach (FrontDesk fd in frontDesks)
- {
- sb.Append(fd.toString()).Append("\n");
- }
- return sb.ToString();
- }
- public bool CheckForDesks(Client client)
- {
- if (client.FrontDeskNumber < 0 || client.FrontDeskNumber >= numberOfDesks)
- return false;
- return true;
- }
- public int CalculatePrice()
- {
- int sum = 0;
- foreach(FrontDesk fd in frontDesks)
- {
- sum += fd.calculatePrice();
- }
- return sum;
- }
- public FrontDesk CheckIfDeskExists(int FrontDeskNumber)
- {
- foreach (FrontDesk fd in frontDesks)
- {
- if (fd.Number ==FrontDeskNumber)
- return fd;
- }
- return null;
- }
- public double success()
- {
- int numDeskClients = 0;
- foreach(FrontDesk fd in frontDesks)
- {
- numDeskClients += fd.GetClientLength();
- }
- return (double)(numDeskClients / clients.Count);
- }
- }
- class Program
- {
- public static void Start(TouristAgency touristAgency)
- {
- while (true)
- {
- int n = int.Parse(Console.ReadLine());
- switch (n)
- {
- case 1:
- Client client = ClientParser();
- touristAgency.ClientService(client);
- break;
- case 2:
- int frontDeskNumber = int.Parse(Console.ReadLine());
- touristAgency.GetNumberOfClients(frontDeskNumber);
- break;
- case 3:
- int frontDeskNumber1 = int.Parse(Console.ReadLine());
- touristAgency.GetPriceFromDesk(frontDeskNumber1);
- break;
- case 4:
- Console.Write(touristAgency.toString());
- break;
- case 5:
- Console.Write(touristAgency.CalculatePrice());
- break;
- case 6:
- Console.Write(touristAgency.success());
- break;
- case 7:
- return;
- }
- }
- }
- public static Client ClientParser()
- {
- string name = Console.ReadLine();
- string surename = Console.ReadLine();
- int age = int.Parse(Console.ReadLine());
- string destination = Console.ReadLine();
- int frontDeskNumber = int.Parse(Console.ReadLine());
- Client client = new Client(name, surename, age, destination, frontDeskNumber);
- return client;
- }
- static void Main(string[] args)
- {
- TouristAgency touristAgency = new TouristAgency("World", 5);
- Start(touristAgency);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement