Advertisement
wingman007

2018_CursovaRabotaProgram

May 29th, 2018
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 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. namespace Store
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int capacity;
  14.             do
  15.             {
  16.                 capacity = 0;
  17.                 Console.Write("Please eneter the number of the clients: ");
  18.                 try
  19.                 {
  20.                     capacity = Int32.Parse(Console.ReadLine());
  21.                 }
  22.                 catch (Exception)
  23.                 {
  24.  
  25.                     Console.WriteLine("Please be nice!!!");
  26.                 }
  27.                
  28.             } while (capacity > 500 || capacity < 1);
  29.  
  30.             Customer[] customers = new Customer[capacity];
  31.             for (var i = 0; i < capacity; i++)
  32.             {
  33.                 customers[i] = InputCustomer();
  34.             }
  35.  
  36.         }
  37.  
  38.         public static Customer InputCustomer()
  39.         {
  40.             Customer customer = new Customer();
  41.             customer.FullName = InputStringWithlenght("Full Name", 30);
  42.             customer.Town = InputStringWithlenght("Town", 10);
  43.             customer.Town = InputStringWithlenght("Code", 10);
  44.             return customer;
  45.         }
  46.  
  47.         public static string InputStringWithlenght(string itemName, int lenght)
  48.         {
  49.             string item;
  50.             do
  51.             {
  52.                 Console.Write("Please, enter {0} (max lenght {1}): ", itemName, lenght);
  53.                 item = Console.ReadLine();
  54.             } while (item.Length > lenght);
  55.             return item;
  56.         }
  57.  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement