Question
Make this code workable or make me another code of this type by watching the uml diagram its an bike rental service in C++ #include
Make this code workable or make me another code of this type by watching the uml diagram
its an bike rental service in C++
#include
public:
Vehicle() {
}
int get_no() { return this->no; }
string get_model() { return this->model; }
float get_price(int rentalDays) { return this->price24h*rentalDays; } virtual void print()=0; };
class Bike: public Vehicle { public:
Bike(int no, string model) { this->no = no; this->model = model; this->price24h = price24h; } virtual
void print() { coutnomodel
class EMotorVehicle: public Vehicle { public: EMotorVehicle(int no,string model,float price24h) { this->no = no; this->model = model; this->price24h = 9.99; } EMotorVehicle() {
}
virtual bool is_streetLegal()=0;
void print() { if(!this->is_streetLegal()) coutnomodel
class EBike: public EMotorVehicle { public: EBike(int no,string model,float price24h = 29.99) { this->no = no; this->model = model; this->price24h = price24h; } bool is_streetLegal() { return true; }
void print() { cout
};
class EScooter: public EMotorVehicle { private: bool streetLegal; public: EScooter(int no,string model,float price24h = 19.99,bool streeLegal=false) { this->no = no; this->model = model; this->price24h = price24h; this->streetLegal = streetLegal; } bool is_streetLegal() { return this->streetLegal; } void print() { cout
class DayOfYear { private: unsigned short dayOfYear; unsigned short year; const unsigned static short days[]; //12 months + 0 for the 1st January
public:
DayOfYear(short dayOfYear =1,short year=365) { this->dayOfYear = dayOfYear; this->year = year; }
DayOfYear(int day, int month, int year) { this->dayOfYear = getDayOfYear(day,month); this->year = year; }
short getDayOfYear(int day, int month) { short dayOfYear=0 ; for(int i=0;i short get_dayOfYear() { return this->dayOfYear; } DayOfYear operator++() { short newYear; short newDayOfYear; if(this->dayOfYear%365 == 0) { newYear = this->year+1; newDayOfYear = 1; } newDayOfYear = this->dayOfYear + 1; return DayOfYear(newDayOfYear,newYear); } string getDayAndMonth() { int prevDay; int day = this->dayOfYear; int month=-1; while(day >0) { month++; prevDay = day; day -= days[month]; } return string(prevDay+"/"+month); } ostream& operatorgetDayAndMonth() year; return os; } }; const unsigned short DayOfYear::days[31]={0,31,59,90,120,151,181,212,243,273,304,335,366}; class Rental { private: static const int no = 478; DayOfYear from; // starting day of rental int days; // no. rental days string customer; //renting person name public: Rental() { } int get_days() { return this->days; } DayOfYear get_from() { return this->from; } DayOfYear get_until() { DayOfYear until(this->from); // Creating a new Object of DayOfYear int rentalDays = this->days; while(rentalDays--) { until = ++until; } return until; } void print() { coutfrom.getDayAndMonth()get_until().getDayAndMonth()nocustomer next Schedule head last vehicle Hinweis berladene Konstruktoren, Destruktoren, (Rckgabe) Vehicle Typen, Parameter sowie vererbte Attribute und no : Integer - model : String Methoden sind in der Darstellung der (Unter-) - price24h : Real Klassen jeweils + Vehicle) weggelassen./ + get_no() Hint + get_model() Overloaded constructors, destructors, (return) types, + get_pricel) parameters as well as + print() inherited attributes and methods are omitted in the (sub)classes. EMotor Vehicle + Schedule() + get_vehicle() + get_next() + set_next() +isFreel) + book() +print() Agency profitPercent : Real - profit : Real + Agency() + get_profit() + set_profitPercent() + add() + isFreel) + book() + choose Vehicle) + print() #searchFor() Bike + EMotor Vehicle() + isStreetLegal) +print() + Bike() + print() from EBike 365 year Rental no : Integer - lastNo: Integer - days: Integer - customer : String + Rental() + get_from() + get_until) + print() EScooter - streetLegal: Boolean + EScooter() + isStreetLegal() + print() DayOfYear - dayOfYear: Integer -year : Integer days: Integer[] + DayOfYear() + get_dayOfYear() + operator++0) + operator>() + EBike() + isStreetLegal) +print()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started