-
Notifications
You must be signed in to change notification settings - Fork 0
/
house.cpp
109 lines (92 loc) · 2.59 KB
/
house.cpp
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
#include "house.h"
#include <iostream>
#include <string>
using namespace std;
House::House(int roomCount, float length, float breadth, float height, string description) {
this -> roomCount = roomCount;
this -> length = length;
this -> breadth = breadth;
this -> height = height;
this -> description = description;
}
House::~House() {
cout << "Demolishing house" << endl;
}
// Getter for House instance variables
int House::getter(int variable) {
return variable;
}
// Over-loaded getter for House instance variables
string House::getter(string variable) {
return variable;
}
// Over-loaded getter for House instance variables
float House::getter(float variable) {
return variable;
}
// Getter for roomCount variable
int House::getRoomCount() {
return getter(roomCount);
}
// Getter for length variable
float House::getLength() {
return getter(length);
}
// Getter for breadth variable
float House::getBreadth() {
return getter(breadth);
}
// Getter for height variable
float House::getHeight() {
return getter(height);
}
// Getter for house description variable
string House::getDescription() {
return getter(description);
}
// Setter for roomCount variable
void House::setRoomCount(int roomCount) {
this -> roomCount = roomCount;
}
// Setter for length variable
void House::setLength(float length) {
this -> length = length;
}
// Setter for breadth variable
void House::setBreadth(float breadth) {
this -> breadth = breadth;
}
// Setter for height variable
void House::setHeight(float height) {
this -> height = height;
}
// Setter for house description variable
void House::setDescription(string description) {
this -> description = description;
}
/*
int main() {
int sampleRoomCount = 2;
float sampleLength = 12.8;
float sampleBreadth = 8.5;
float sampleHeight = 4.9;
string sampleDescription = "This house is small with two all-purpose rooms.";
House thing(sampleRoomCount, sampleLength, sampleBreadth, sampleHeight, sampleDescription);
cout << thing.getRoomCount() << endl;
cout << thing.getLength() << endl;
cout << thing.getBreadth() << endl;
cout << thing.getHeight() << endl;
cout << thing.getDescription() << endl;
thing.setRoomCount(5);
thing.setLength(21.6);
thing.setBreadth(38.1);
thing.setHeight(6);
thing.setDescription("This house is big with 5 rooms.");
cout << thing.getRoomCount() << endl;
cout << thing.getLength() << endl;
cout << thing.getBreadth() << endl;
cout << thing.getHeight() << endl;
cout << thing.getDescription() << endl;
return 0;
}
*/