51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
class CarSpotController {
|
|
|
|
private:
|
|
int total_spots;
|
|
int occupied_spots;
|
|
|
|
public:
|
|
CarSpotController(int default_total_spots) {
|
|
this->set_total_spots(default_total_spots);
|
|
}
|
|
|
|
int get_total_spots() {
|
|
return this->total_spots;
|
|
}
|
|
|
|
void set_total_spots(int total_spots) {
|
|
this->total_spots = total_spots;
|
|
}
|
|
|
|
int get_occupied_spots() {
|
|
return this->occupied_spots;
|
|
}
|
|
|
|
void set_occupied_spots(int occupied_spots) {
|
|
this->occupied_spots = occupied_spots;
|
|
}
|
|
|
|
void increment_occupied_spots () {
|
|
this->occupied_spots++;
|
|
}
|
|
|
|
void increment_total_spots () {
|
|
this->total_spots++;
|
|
}
|
|
|
|
void decrement_total_spots () {
|
|
this->total_spots--;
|
|
}
|
|
|
|
void decrement_occupied_spots () {
|
|
this->occupied_spots--;
|
|
}
|
|
|
|
bool is_full() {
|
|
return this->occupied_spots == this->total_spots;
|
|
}
|
|
|
|
bool is_empty() {
|
|
return this->occupied_spots == 0;
|
|
}
|
|
}; |