-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab6_Question1.cs
More file actions
125 lines (95 loc) · 3.15 KB
/
Copy pathLab6_Question1.cs
File metadata and controls
125 lines (95 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Question1
{
class CreditLimitException: Exception
{
public CreditLimitException(string message):base(message)
{
}
}
class Customer
{
//fields
private string _customerId;
private string _customerName;
private string _address;
private string _city;
private string _phone;
private int _creditLimit;
//properties
public string CustomerId { get => _customerId; set => _customerId = value; }
public string CustomerName { get => _customerName; set => _customerName = value; }
public string Address { get => _address; set => _address = value; }
public string City { get => _city; set => _city = value; }
public string Phone { get => _phone; set => _phone = value; }
public int CreditLimit
{
set
{
if (value <= 50000)
{
_creditLimit = value;
}
else
{
throw new Exception("Credit limit must be less than 50000");
}
}
get
{
return _creditLimit;
}
}
public Customer()
{
CustomerId = "";
CustomerName = "";
Address = "";
City = "";
Phone = "";
CreditLimit = 0;
}
public Customer(string CustomerId, string CustomerName, string Address, string City, string Phone, int CreditLimit)
{
this.CustomerId = CustomerId;
this.CustomerName = CustomerName;
this.Address = Address;
this.City = City;
this.Phone = Phone;
this.CreditLimit = CreditLimit;
}
}
class Program
{
static void Main(string[] args)
{
try
{
Customer cust = new Customer();
Console.WriteLine("Customer Id");
cust.CustomerId = Console.ReadLine();
Console.WriteLine("Customer Name");
cust.CustomerName = Console.ReadLine();
Console.WriteLine("Address");
cust.Address = Console.ReadLine();
Console.WriteLine("City");
cust.City = Console.ReadLine();
Console.WriteLine("Phone");
cust.Phone = Console.ReadLine();
Console.WriteLine("Credit Limit");
cust.CreditLimit =Convert.ToInt32(Console.ReadLine());
}
catch(Exception ex)
{
String content = $"\n\n{DateTime.Now}" +
$"\nMessage: {ex.Message}";
Console.WriteLine(content);
}
Console.ReadKey();
}
}
}