comments...
This commit is contained in:
parent
0eec488dfb
commit
c5d7a7eb60
@ -69,7 +69,6 @@ auto int_to_string(const unsigned int value, const unsigned int digits = 0) -> s
|
||||
*/
|
||||
class date final
|
||||
{
|
||||
private:
|
||||
unsigned short day_;
|
||||
unsigned short month_;
|
||||
unsigned short year_;
|
||||
@ -123,7 +122,6 @@ public:
|
||||
*/
|
||||
class address final
|
||||
{
|
||||
private:
|
||||
string street_;
|
||||
string street_no_;
|
||||
string postal_code_;
|
||||
@ -158,13 +156,13 @@ public:
|
||||
return istr;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Output operator of address
|
||||
* \param ostr output stream
|
||||
* \param address current address
|
||||
* \return output stream
|
||||
*/
|
||||
friend ostream& operator<<(ostream& ostr, const address& address)
|
||||
/**
|
||||
* \brief Output operator of address
|
||||
* \param ostr output stream
|
||||
* \param address current address
|
||||
* \return output stream
|
||||
*/
|
||||
friend ostream& operator<<(ostream& ostr, const address& address)
|
||||
{
|
||||
ostr << "Strasse: " << address.street_ << endl;
|
||||
ostr << "Hausnummer: " << address.street_no_ << endl;
|
||||
@ -174,9 +172,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Customer, represented by name, first name, address, phone and year of birth
|
||||
*/
|
||||
class customer final
|
||||
{
|
||||
private:
|
||||
int id_;
|
||||
string name_;
|
||||
string first_name_;
|
||||
@ -200,6 +200,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Input operator of customer
|
||||
* \param istr input stream
|
||||
* \param customer current address instance
|
||||
* \return output stream
|
||||
*/
|
||||
friend istream& operator>>(istream& istr, customer*& customer)
|
||||
{
|
||||
cout << "Name: ";
|
||||
@ -215,6 +221,12 @@ public:
|
||||
return istr;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Output operator of customer
|
||||
* \param ostr output stream
|
||||
* \param customer current customer instance
|
||||
* \return output stream
|
||||
*/
|
||||
friend ostream& operator<<(ostream& ostr, const customer& customer)
|
||||
{
|
||||
ostr << "Name: " << customer.name_ << endl;
|
||||
@ -226,29 +238,43 @@ public:
|
||||
return ostr;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get name of customer
|
||||
* \return name
|
||||
*/
|
||||
string get_name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get first name of customer
|
||||
* \return first name
|
||||
*/
|
||||
string get_first_name() const
|
||||
{
|
||||
return first_name_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the value, if customer hast driving license
|
||||
* \return True if customer hast driving license. False otherwise.
|
||||
*/
|
||||
bool get_has_driving_license() const
|
||||
{
|
||||
return has_driving_license_;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Reservation of a motorcycle
|
||||
*/
|
||||
class reservation final
|
||||
{
|
||||
private:
|
||||
int id_;
|
||||
date start_;
|
||||
date end_;
|
||||
short motorcycle_ = -1; // => -1 means nothing reserved
|
||||
short motorcycle_index_ = -1; // => -1 means nothing reserved
|
||||
customer* customer_;
|
||||
bool canceled_;
|
||||
public:
|
||||
@ -256,27 +282,43 @@ public:
|
||||
id_(++next_reservation_id),
|
||||
start_(start),
|
||||
end_(end),
|
||||
motorcycle_(motorcycle),
|
||||
motorcycle_index_(motorcycle),
|
||||
customer_(customer),
|
||||
canceled_(false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get start date of reservation
|
||||
* \return date instance
|
||||
*/
|
||||
date get_start_date() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get end date of reservation
|
||||
* \return date instance
|
||||
*/
|
||||
date get_end_date() const
|
||||
{
|
||||
return end_;
|
||||
}
|
||||
|
||||
short get_motorcycle() const
|
||||
/**
|
||||
* \brief get index of motorcycle array
|
||||
* \return integer value of index
|
||||
*/
|
||||
short get_motorcycle_index() const
|
||||
{
|
||||
return motorcycle_;
|
||||
return motorcycle_index_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get pointer of customer, attached to this instance
|
||||
* \return pointer to customer
|
||||
*/
|
||||
customer* get_customer() const
|
||||
{
|
||||
return customer_;
|
||||
@ -458,7 +500,7 @@ bool validate_reservation(reservation* const reservation)
|
||||
const auto end_sum = reservation->get_end_date().get_day_num();
|
||||
for (auto r : reservations)
|
||||
{
|
||||
if (r->get_motorcycle() == reservation->get_motorcycle())
|
||||
if (r->get_motorcycle_index() == reservation->get_motorcycle_index())
|
||||
{
|
||||
if (start_sum < r->get_end_date().get_day_num() && end_sum > r->get_start_date().get_day_num()
|
||||
|| end_sum > r->get_start_date().get_day_num() && end_sum < r->get_end_date().get_day_num())
|
||||
@ -528,7 +570,7 @@ reservation* get_reservation_for_customer(customer* const current_customer)
|
||||
if (reservation->get_customer() == current_customer)
|
||||
{
|
||||
cout << ++index << ". " << reservation->get_start_date() << " - " << reservation->get_end_date() << ": " <<
|
||||
motorcycles[reservation->get_motorcycle()] << endl;
|
||||
motorcycles[reservation->get_motorcycle_index()] << endl;
|
||||
reservations_of_customer.push_back(reservation);
|
||||
}
|
||||
}
|
||||
@ -585,7 +627,7 @@ void export_reservations()
|
||||
for (auto reservation : reservations)
|
||||
{
|
||||
f << reservation->get_id() << ";";
|
||||
f << motorcycles[reservation->get_motorcycle()] << ";";
|
||||
f << motorcycles[reservation->get_motorcycle_index()] << ";";
|
||||
f << reservation->get_start_date() << ";";
|
||||
f << reservation->get_end_date() << ";";
|
||||
f << reservation->get_customer()->get_name() << ";";
|
||||
|
Loading…
x
Reference in New Issue
Block a user