Website Summary Files Commits Branches @commit @diff @stats
path: root / Week08 / Exercise01 / Hangar.h
blob: 29bd5da29003f4683a7ce26b50bd981492b50634 (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
#ifndef _HANGAR
#define _HANGAR

#include "RocketStage.h"
#include "Rocket.h"

class Hangar {
	Rocket* rockets;
	unsigned rocketsCount;
	unsigned rocketsAlloc;

	RocketStage* stages;
	unsigned stagesCount;
	unsigned stagesAlloc;

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

	void resizeRockets();
	void resizeStages();

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

	unsigned AddStage(const RocketStage& stage);
	RocketStage RemoveStage(unsigned stageIndex);

	unsigned AddRocket(const Rocket& rocket);
	const Rocket* GetRocket(unsigned rocketIndex) const;
	void MoveStageToRocket(unsigned rocketIndex, unsigned stageIndex);

	void Export(std::ofstream& outFile) const;
	void Import(std::ifstream& inFile);
};

#endif /* _HANGAR */