-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rentable.cs
160 lines (149 loc) · 4.93 KB
/
Rentable.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Xml.Serialization;
namespace OOP_Project
{
[Serializable()]
public abstract class Rentable : ISerializable
{
private static int idCounter = 0;
private int id;
private string address;
private string description;
private int zipCode;
private double price;
private int residents;
private bool pets;
private bool occupied;
private bool pool;
private bool wifi;
private User user;
public virtual string toString()
{
return "Rentable Information ::"+"\n"+"########################"+"\n"+"ID: " + id +"\nOccupied: "+ occupied+"\nOwner: "+user.Name + "\nAddress: " + address + "\n" + "Zip Code: " + zipCode + "\n" + "Price: " + price + "\n" + "Residents:" + residents + "\n" + "Pets: " + pets + "\n" + "Pool: " + pool + "\n" + "Wifi: " + wifi + "\n" + "Description: " + description + "\n"+"###########"+"\n";
}
public string getText()
{
if (this.occupied )
{
return Address + "\n" + price + "\n" + "Not Available";
}
return Address + "\n" + Price;
}
public Rentable(SerializationInfo info, StreamingContext context)
{
idCounter = (int)info.GetValue("IdCounter", typeof(int));
id = (int)info.GetValue("Id",typeof(int));
address=(string)info.GetValue("Address",typeof(string));
description=(string)info.GetValue("Description",typeof(string));
zipCode = (int)info.GetValue("ZipCode",typeof(int));
price=(double)info.GetValue("Price",typeof(double));
residents=(int)info.GetValue("Residents",typeof(int));
pets=(bool)info.GetValue("Pets",typeof(bool));
occupied = (bool)info.GetValue("Occupied", typeof(bool));
wifi = (bool)info.GetValue("Wifi", typeof(bool));
user = (User)info.GetValue("User", typeof(User));
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("IdCounter", idCounter);
info.AddValue("Id", Id);
info.AddValue("Address", Address);
info.AddValue("Description", Description);
info.AddValue("ZipCode", ZipCode);
info.AddValue("Price",Price);
info.AddValue("Residents", Residents);
info.AddValue("Pets", Pets);
info.AddValue("Occupied", Occupied);
info.AddValue("Pool", Pool);
info.AddValue("Wifi", Wifi);
info.AddValue("User", user);
}
public Rentable()
{
this.id = idCounter++;
this.address = "";
this.description = "";
this.price = 0;
this.zipCode = 0;
this.residents = 0;
this.pets = false;
this.pool = false;
this.wifi = false;
this.occupied = false;
this.user = null;
}
public Rentable(string address,string description,int zipCode,double price, int residents, bool pets, bool pool,bool wifi,User user)
{
this.id = idCounter++;
this.address = address;
this.description = description;
this.zipCode = zipCode;
this.price = price;
this.residents = residents;
this.pets = pets;
this.pool = pool;
this.wifi = wifi;
this.occupied = false;
this.user = user;
}
public bool Occupied
{
get { return occupied; }
set { occupied = value; }
}
public int Id
{
get { return id; }
}
public string Address
{
get { return address; }
set { address = value; }
}
public int ZipCode
{
get { return zipCode; }
set { zipCode = value; }
}
public double Price
{
get { return price; }
set { price = value; }
}
public bool Pets
{
get { return pets; }
set { pets = value; }
}
public int Residents
{
get { return residents; }
set { residents = value; }
}
public string Description
{
get { return description; }
set { description = value; }
}
public bool Pool
{
get { return pool; }
set { pool = value; }
}
public bool Wifi
{
get { return wifi; }
set { wifi = value; }
}
public User User
{
get { return user; }
set { user = value; }
}
}
}