-
Notifications
You must be signed in to change notification settings - Fork 0
/
PetHotel.cs
143 lines (127 loc) · 3.4 KB
/
PetHotel.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
class Pet
{
private bool type; // true for dog, false for cat
private string name;
private uint age;
private bool gender; // true for male, fallse for female
private uint idNumber;
private bool isHere;
public Pet()
{
this.type = false;
this.name = "";
this.age = 0;
this.gender = false;
this.idNumber = 0;
this.isHere = false;
}
public void InitValues(bool type,string name, uint age, bool gender, uint idNumber, bool isHere)
{
this.type = type;
this.name = name;
this.age = age;
this.gender = gender;
this.idNumber = idNumber;
this.isHere = isHere;
}
public Pet(bool type, string name, uint age, bool gender, uint idNumber, bool isHere) => InitValues(type, name, age, gender, idNumber, isHere);
public void print()
{
Console.WriteLine("The name of the pet is : {0}", name);
if(type)
{
Console.WriteLine("The type of the pet is dog. ");
}
else
{
Console.WriteLine("The type of the pet is cat. ");
}
if(gender)
{
Console.WriteLine("The gender of the pet is male. ");
}
else
{
Console.WriteLine("The gender of the pet is female. ");
}
Console.WriteLine("The age of the pet is : {0} ", age);
Console.WriteLine("The Id number of the pet is : {0} ", idNumber);
if (isHere)
{
Console.WriteLine("The pet is in the hotel. ");
}
else
{
Console.WriteLine("The pet is not in the hotel. ");
}
}
public string getName()
{
return this.name;
}
public bool getIsHere()
{
return isHere;
}
public void changeStatus()
{
this.isHere = !isHere;
}
}
class PetHotel
{
private Pet[] hotelArray = new Pet[20];
private uint countOfPets;
public PetHotel()
{
for(int i = 0; i < 20; i++)
{
hotelArray[i] = new Pet();
}
countOfPets = 0;
}
public void changeStatus(string name)
{
foreach(Pet i in hotelArray)
{
if(i.getName() == name)
{
i.changeStatus();
}
}
}
public bool addPet(Pet forAdd)
{
for(int i = 0; i < 20; i++)
{
if (!hotelArray[i].getIsHere())
{
hotelArray[i] = forAdd;
return true;
}
}
Console.WriteLine("No place for this pet ! ");
return false;
}
public void print()
{
foreach(Pet i in hotelArray)
{
i.print();
}
}
}
class Program
{
static void Main(string[] args)
{
}
}
}