Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Hall.cpp
blob: d1c25f7c70c8e1c4a09c83e593b2770533b0cf00 (plain) (blame)
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
#include "Hall.h"

Hall::Hall() : Hall(0, 0, 0) {}

Hall::Hall(int number) : Hall(number, 0, 0) {}

Hall::Hall(int number, unsigned rows, unsigned seatsPerRow) {
	this->number = number;
	this->rows = rows;
	this->seatsPerRow = seatsPerRow;
}

int Hall::get_number() const {
	return number;
}
unsigned Hall::get_rows() const {
	return rows;
}

unsigned Hall::get_seatsPerRow() const {
	return seatsPerRow;
}

void Hall::read(std::istream& istr) {
	istr.read((char*)&number, sizeof(number));
	istr.read((char*)&rows, sizeof(rows));
	istr.read((char*)&seatsPerRow, sizeof(seatsPerRow));
}

void Hall::write(std::ostream& ostr) const {
	ostr.write((char*)&number, sizeof(number));
	ostr.write((char*)&rows, sizeof(rows));
	ostr.write((char*)&seatsPerRow, sizeof(seatsPerRow));
}

int Hall::compare(const Hall& other) const {
	return (number > other.get_number()) - (number < other.get_number());
}

std::istream& operator>>(std::istream& istr, Hall& hall) {
	int number;
	unsigned rows, seatsPerRow;
	istr >> number >> rows >> seatsPerRow;
	hall = Hall(number, rows, seatsPerRow);
	return istr;
}

std::ostream& operator<<(std::ostream& ostr, const Hall& hall) {
	return ostr << hall.get_number() << " " << hall.get_rows() << " "<< hall.get_seatsPerRow();
}