Advertisement
Guest User

Untitled

a guest
Dec 27th, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class PCCatalog
  9. {
  10. static void Main()
  11. {
  12. List<Computer> computers = ComputersAdd();
  13. foreach (Computer computer in computers)
  14. {
  15. Console.WriteLine(computer.ToString());
  16. Console.WriteLine();
  17.  
  18. }
  19.  
  20. }
  21. static List<Component> ComponentsAdd()
  22. {
  23. List<Component> components = new List<Component>();
  24. string checker = null;
  25. do
  26. {
  27. Console.WriteLine("Please add component name:");
  28. string name = Console.ReadLine();
  29. Console.WriteLine("Please add component details or press enter if not available:");
  30. string details = Console.ReadLine();
  31. Console.WriteLine("Please enter component price in BGN");
  32. float price = float.Parse(Console.ReadLine());
  33. Component component = new Component(name, price, details);
  34. components.Add(component);
  35. Console.WriteLine("Would you like to enter another component? Y\\N");
  36. checker = Console.ReadLine();
  37. } while (checker != "N" && checker != "n");
  38. return components;
  39. }
  40. static List<Computer> ComputersAdd()
  41. {
  42. List<Computer> computers = new List<Computer>();
  43. string checker = null;
  44. do
  45. {
  46. Console.WriteLine("Please enter computer name: ");
  47. string name = Console.ReadLine();
  48. List<Component> components = ComponentsAdd();
  49.  
  50. Computer computer = new Computer(name, components);
  51. computers.Add(computer);
  52. Console.WriteLine("Would you like to add another computer? Y\\N");
  53. checker = Console.ReadLine();
  54. } while (checker != "N" && checker != "n");
  55. return computers;
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement