Website Summary Files Commits Branches @commit @diff @stats
path: root / Week08 / Exercise01 / SpaceAgency.h
blob: 38f3e5aaf0b5eb8ea3bb6589bc16df09f57fdff2 (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
#ifndef _SPACE_AGENCY
#define _SPACE_AGENCY

#include "Hangar.h"
#include "LaunchSite.h"

class SpaceAgency {
	Hangar* hangars;
	unsigned hangarsCount;
	unsigned hangarsAlloc;

	LaunchSite* sites;
	unsigned sitesCount;
	unsigned sitesAlloc;

	void free();
	void copyFrom(const SpaceAgency& other);

	void resizeHangars();
	void resizeSites();

public:
	SpaceAgency();
	~SpaceAgency();
	SpaceAgency(const SpaceAgency& other);
	SpaceAgency& operator=(const SpaceAgency& other);
	SpaceAgency(SpaceAgency&& other);
	SpaceAgency& operator=(SpaceAgency&& other);

	void AddHangar(const Hangar& hangar);
	Hangar* GetHangar(unsigned hangarIndex);
	const Hangar* GetHangar(unsigned hangarIndex) const;

	void AddLaunchSite(const LaunchSite& site);
	LaunchSite* GetLaunchSite(unsigned launchSiteIndex);
	const LaunchSite* GetLaunchSite(unsigned launchSiteIndex) const;

	void AddRocketStage(const RocketStage& stage, unsigned hangarIndex);

	unsigned AddRocket(const Rocket& rocket, unsigned hangarIndex);
	void MoveRocketStageToRocket(unsigned stageHangar, unsigned stageIndex, unsigned rocketHangar, unsigned rocketIndex);

	bool CanLaunch(unsigned siteIndex, unsigned hangarIndex, unsigned rocketIndex) const;
};

#endif /* _SPACE_AGENCY */