-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ship.h
91 lines (63 loc) · 1.98 KB
/
Ship.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// Created by Admin on 6/18/2021.
//
#ifndef UNTITLED2_SHIP_H
#define UNTITLED2_SHIP_H
#include <string>
#include <limits>
#include <iostream>
#include <utility>
#include <cmath>
#include <memory>
#include "Sim_object.h"
#define FREIGHTER_FUEL_TANK_CAPACITY 900
#define FREIGHTER_MAX_SPEED 15
#define FREIGHTER_CONSUMPTION 2000
#define PATROL_BOAT_FUEL_TANK_CAPACITY 900
#define PATROL_BOAT_MAX_SPEED 15
#define PATROL_BOAT_CONSUMPTION 2000
#define Cruiser_MAX_SPEED 75
#define MAX_CONTAINERS_IN_FREIGHTER 20
#define INFINITE_POINT Point(std::numeric_limits<double>::max(), std::numeric_limits<double>::max())
enum state {
Stopped, Docked, Dead, MovingTo, MovingOnCourse
};
class Ship: public Sim_object {
protected:
state _currentState;
Point _position;
double _speed;
double _angle;
Point _currentDestination;
std::string _currentPort;
public:
Ship(std::string new_name, Point position, object_type type) :
Sim_object(new_name, type), _currentState(Stopped), _position(
position), _speed(0), _angle(90) {
}
;
virtual void update() =0;
void Position(double x, double y, double newSpeed);
void Course(double angle, double speed, const Point &destination =
INFINITE_POINT);
void destination(double new_speed, const std::string &portName);
double getAngle() const;
void setAngle(double angle);
void stop();
void printStatus(std::string end = "\n");
double getSpeed() const;
void setSpeed(double speed);
const Point& getPosition() const override;
void setPosition(const Point &position);
const Point& getDestination() const;
void setDestination(const Point &destination);
state getCurrentState() const;
void setCurrentState(state currentState);
static std::string getState_Name(state s);
virtual ~Ship() = default;
void status() override;
};
double calc_angle(const Point &origin, const Point &destination);
bool MoveAgent(Point &origin, const Point &destination, const double &speed,
double angle2 = std::numeric_limits<double>::max());
#endif //UNTITLED2_SHIP_H