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 income;
- public List<Client> deskClients;
- public int Income { get {return income;} set {income=value;} }
- public FrontDesk() {
- deskClients=new List<Client>();
- }
- public void addClient(Client client) {
- deskClients.Add(client);
- }
- public int GetClientLength() {
- return deskClients.Count;
- }
- public int GetClientsForDestination(string destination) {
- int karti=0;
- foreach(Client c in deskClients) {
- if(c.Destination.Equals(destination)) {
- karti++;
- }
- }
- return karti;
- }
- public int calculatePrice() {
- int suma=0;
- foreach(Client c in deskClients) {
- suma+=c.getPrice();
- }
- return suma;
- }
- public string toString() {
- StringBuilder sb=new StringBuilder();
- foreach(Client c in deskClients) {
- sb.Append(c.Destination).Append("-").Append(GetClientsForDestination(c.Destination)).Append("\n");
- }
- return sb.ToString();
- }
- }
- class TouristAgency
- {
- private string name;
- List<Client> clients;
- List<FrontDesk> frontDesks;
- List<String> destinations;
- public TouristAgency(String name)
- {
- this.name = name;
- clients = new List<Client>();
- frontDesks=new List<FrontDesk>();
- 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)) {
- frontDesks[client.FrontDeskNumber-1].addClient(client);
- }
- }
- public void GetNumberOfClients(int frontDeskNumber) {
- Console.Write(frontDesks[frontDeskNumber-1].GetClientLength());
- }
- public int GetPriceFromDesk(int frontDeskNumber) {
- return frontDesks[frontDeskNumber-1].calculatePrice();
- }
- public string toString() {
- StringBuilder sb=new StringBuilder();
- foreach(FrontDesk fd in frontDesks)
- {
- sb.Append(fd).Append("\n");
- }
- return sb.ToString();
- }
- }
- 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;
- }
- }
- }
- 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");
- Start(touristAgency);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement