Mam napisany kod na temat rezerwacji pokoi w Hotelu, mamy klasy osoba, gosc, pokoj, rezerwacja i hotel. I moje pytanie brzmi czy ten diagram UML jest odpowiedni dla tego kodu? Proszę o pomoc, strasznie długo nad tym siedzę i główkuje, ponieważ mam problem z diagramem i relacjami Rezerwacji, a muszę mieć 100% pewność.
#ifndef HOTEL_H
#define HOTEL_H
#include "Pokoj.h"
#include "Gosc.h"
#include "Rezerwacja.h"
#include <vector>
#include <map>
#include <string>
#include <stdexcept>
class Hotel {
private:
std::vector<Pokoj> pokoje = {
Pokoj(101, "Jednoosobowy"),
Pokoj(102, "Dwuosobowy"),
Pokoj(103, "Apartament"),
Pokoj(104, "Jednoosobowy"),
Pokoj(105, "Dwuosobowy")
};
std::vector<Gosc> goscie;
std::map<int, Rezerwacja> rezerwacje;
public:
void dodajGoscia(const Gosc& gosc);
bool czyIdGosciaJestUnikalne(int idGoscia) const;
bool dokonajRezerwacji(int numerPokoju, int idGoscia, const std::string& dataRozpoczecia, const std::string& dataZakonczenia);
bool anulujRezerwacje(int idGoscia);
Pokoj* znajdzPokoj(int numerPokoju);
Gosc* znajdzGoscia(int idGoscia);
std::vector<Pokoj> pobierzDostepnePokoje(const std::string& dataRozpoczecia, const std::string& dataZakonczenia) const;
bool zapiszGosciDoPliku(const std::string& nazwaPliku);
bool wczytajGosciZPliku(const std::string& nazwaPliku);
bool zapiszRezerwacjeDoPliku(const std::string& nazwaPliku);
bool wczytajRezerwacjeZPliku(const std::string& nazwaPliku);
const std::map<int, Rezerwacja>& pobierzRezerwacje() const { return rezerwacje; }
}
#endif // HOTEL_H
#ifndef GOSC_H
#define GOSC_H
#include "Osoba.h"
class Gosc : public Osoba {
private:
int idGoscia;
public:
Gosc() : Osoba("", ""), idGoscia(0) {}
Gosc(const std::string& imie, const std::string& nazwisko, int id);
virtual void wyswietlInformacje() const override;
int pobierzIdGoscia() const;
std::string pobierzImie() const; // getter for imie
std::string pobierzNazwisko() const; // getter for nazwisko
#endif // GOSC_H
#ifndef OSOBA_H
#define OSOBA_H
#include <string>
class Osoba {
protected:
std::string imie;
std::string nazwisko;
public:
Osoba(const std::string& imie, const std::string& nazwisko);
virtual void wyswietlInformacje() const = 0; // Metoda czysto wirtualna
};
#endif // OSOBA_H
#ifndef POKOJ_H
#define POKOJ_H
#include <iostream>
#include <string>
class Pokoj {
private:
int numerPokoju;
std::string typ;
bool status; // true = dostępny, false = zarezerwowany
public:
Pokoj() : numerPokoju(0), typ(""), status(true) {}
Pokoj(int numer, const std::string& typ);
int pobierzNumerPokoju() const;
std::string pobierzTyp() const;
bool pobierzStatus() const;
void ustawStatus(bool nowyStatus);
bool operator==(const Pokoj& other) const;
friend std::ostream& operator<<(std::ostream& os, const Pokoj& pokoj);
};
#endif // POKOJ_H
#ifndef REZERWACJA_H
#define REZERWACJA_H
#include "Pokoj.h"
#include "Gosc.h"
#include <string>
class Rezerwacja {
private:
Pokoj pokoj;
Gosc gosc;
std::string dataRozpoczecia;
std::string dataZakonczenia;
bool anulowana;
public:
Rezerwacja() : anulowana(false) {}
Rezerwacja(const Pokoj& pokoj, const Gosc& gosc, const std::string& dataRozpoczecia, const std::string& dataZakonczenia);
void wyswietlInformacje() const;
int pobierzNumerPokoju() const;
int pobierzIdGoscia() const;
std::string pobierzDataRozpoczecia() const;
std::string pobierzDataZakonczenia() const;
void ustawStatusAnulowanej();
bool czyAnulowana() const;
}
#endif // REZERWACJA_H
Stworzyłem taki diagram, ale niestety nie jestem pewny co do niego i proszę o pomoc
HOTEL
GOSC-------------kompozycja------