-
Notifications
You must be signed in to change notification settings - Fork 1
/
Address.cs
87 lines (75 loc) · 2.29 KB
/
Address.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace task_2
{
internal class Address
{
private string street;
private int numberOfStreet;
private string city;
private string country;
public Address(string street, int numberOfStreet, string city, string country)
{
SetAdress(street, numberOfStreet, city, country);
}
public Address(Address addr)
{
SetAdress(addr.street, addr.numberOfStreet, addr.city, addr.country);
}
public bool SetAdress(string street, int numberOfStreet, string city, string country)
{
if (SetStreet(street) && SetNumberOfStreet(numberOfStreet) && SetCity(city) && SetCountry(country))
{
return true;
}
return false;
}
bool SetStreet(string street)
{
if (street != null && !Validation.IsContainDigit(street))
{
this.street = street;
return true;
}
return false;
}
bool SetNumberOfStreet(int numberOfStreet)
{
if (numberOfStreet > 0 && numberOfStreet < 999)
{
this.numberOfStreet = numberOfStreet;
return true;
}
return false;
}
bool SetCity(string city)
{
if (city != null && !Validation.IsContainDigit(city))
{
this.city = city;
return true;
}
return false;
}
bool SetCountry(string country)
{
if (country != null && !Validation.IsContainDigit(country))
{
this.country = country;
return true;
}
return false;
}
public string GetStreet() { return street; }
public string GetCity() { return city; }
public string GetCountry() { return country; }
public int GetNumberOfStreet() { return numberOfStreet; }
public string ToString()
{
return "Country: " + country + ", city: " + city + ", street: " + street + ", number: " + numberOfStreet;
}
}
}