Advertisement
Guest User

dimsaaaaa

a guest
Feb 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Text;
  4. using System.Collections.Generic;
  5.  
  6. namespace TouristAgency
  7. {
  8. class Client
  9. {
  10. private string name;
  11. private string surename;
  12. private int age;
  13. private string destination;
  14. private int frontDeskNumber;
  15.  
  16. public string Name { get { return name; } set { name = value; } }
  17. public string Surename { get { return surename; } set { surename = value; } }
  18. public int Age { get { return age; } set { age = value; } }
  19. public string Destination { get { return destination; } set { destination = value; } }
  20. public int FrontDeskNumber { get { return frontDeskNumber; } set { frontDeskNumber = value; } }
  21.  
  22. public Client(string name,string surename,int age,string destination,int frontDeskNumber)
  23. {
  24. this.name = name;
  25. this.surename = surename;
  26. this.age = age;
  27. this.destination = destination;
  28. this.frontDeskNumber = frontDeskNumber;
  29. }
  30.  
  31. public int getPrice() {
  32. return destination.Length*2000;
  33. }
  34.  
  35. }
  36.  
  37. class FrontDesk
  38. {
  39. private int income;
  40. public List<Client> deskClients;
  41.  
  42. public int Income { get {return income;} set {income=value;} }
  43.  
  44. public FrontDesk() {
  45. deskClients=new List<Client>();
  46. }
  47.  
  48. public void addClient(Client client) {
  49. deskClients.Add(client);
  50. }
  51.  
  52. public int GetClientLength() {
  53. return deskClients.Count;
  54. }
  55.  
  56. public int GetClientsForDestination(string destination) {
  57. int karti=0;
  58. foreach(Client c in deskClients) {
  59. if(c.Destination.Equals(destination)) {
  60. karti++;
  61. }
  62. }
  63. return karti;
  64. }
  65.  
  66. public int calculatePrice() {
  67. int suma=0;
  68. foreach(Client c in deskClients) {
  69. suma+=c.getPrice();
  70. }
  71. return suma;
  72. }
  73.  
  74. public string toString() {
  75. StringBuilder sb=new StringBuilder();
  76. foreach(Client c in deskClients) {
  77. sb.Append(c.Destination).Append("-").Append(GetClientsForDestination(c.Destination)).Append("\n");
  78. }
  79. return sb.ToString();
  80. }
  81.  
  82. }
  83.  
  84. class TouristAgency
  85. {
  86. private string name;
  87. List<Client> clients;
  88. List<FrontDesk> frontDesks;
  89. List<String> destinations;
  90.  
  91. public TouristAgency(String name)
  92. {
  93. this.name = name;
  94. clients = new List<Client>();
  95. frontDesks=new List<FrontDesk>();
  96. destinations=new List<string>();
  97. createDestinations();
  98. }
  99.  
  100. public void createDestinations() {
  101. destinations.Add("Rim");
  102. destinations.Add("London");
  103. destinations.Add("Tokio");
  104. destinations.Add("Sofija");
  105. destinations.Add("Istanbul");
  106. destinations.Add("Toronto");
  107. destinations.Add("Majami");
  108. destinations.Add("Zagreb");
  109. destinations.Add("Belgrad");
  110. destinations.Add("Moskva");
  111. }
  112.  
  113. public void ClientService(Client client)
  114. {
  115. clients.Add(client);
  116. if(destinations.Contains(client.Destination)) {
  117. frontDesks[client.FrontDeskNumber-1].addClient(client);
  118. }
  119. }
  120.  
  121. public void GetNumberOfClients(int frontDeskNumber) {
  122. Console.Write(frontDesks[frontDeskNumber-1].GetClientLength());
  123. }
  124.  
  125. public int GetPriceFromDesk(int frontDeskNumber) {
  126.  
  127. return frontDesks[frontDeskNumber-1].calculatePrice();
  128. }
  129.  
  130. public string toString() {
  131. StringBuilder sb=new StringBuilder();
  132. foreach(FrontDesk fd in frontDesks)
  133. {
  134. sb.Append(fd).Append("\n");
  135. }
  136. return sb.ToString();
  137. }
  138.  
  139.  
  140. }
  141.  
  142. class Program
  143. {
  144. public static void Start(TouristAgency touristAgency)
  145. {
  146. while (true)
  147. {
  148. int n = int.Parse(Console.ReadLine());
  149.  
  150. switch (n)
  151. {
  152. case 1:
  153. Client client = ClientParser();
  154. touristAgency.ClientService(client);
  155. break;
  156. case 2:
  157. int frontDeskNumber=int.Parse(Console.ReadLine());
  158. touristAgency.GetNumberOfClients(frontDeskNumber);
  159. break;
  160. case 3:
  161. int frontDeskNumber1=int.Parse(Console.ReadLine());
  162. touristAgency.GetPriceFromDesk(frontDeskNumber1);
  163. break;
  164. case 4:
  165. Console.Write(touristAgency.ToString());
  166. break;
  167. }
  168. }
  169. }
  170.  
  171. public static Client ClientParser()
  172. {
  173. string name = Console.ReadLine();
  174. string surename = Console.ReadLine();
  175. int age = int.Parse(Console.ReadLine());
  176. string destination = Console.ReadLine();
  177. int frontDeskNumber = int.Parse(Console.ReadLine());
  178. Client client = new Client(name, surename, age, destination, frontDeskNumber);
  179. return client;
  180. }
  181.  
  182. static void Main(string[] args)
  183. {
  184. TouristAgency touristAgency = new TouristAgency("World");
  185. Start(touristAgency);
  186. }
  187. }
  188.  
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement