-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "price.h" | ||
|
||
int ChildrensPrice::getPriceCode() | ||
{ | ||
return Movie::CHILDRENS; | ||
} | ||
|
||
double ChildrensPrice::getCharge(int daysRented) | ||
{ | ||
double result = 1.5; | ||
if(daysRented > 3) | ||
result += (daysRented - 3) * 1.5; | ||
return result; | ||
} | ||
|
||
int NewReleasePrice::getPriceCode() | ||
{ | ||
return Movie::NEW_RELEASE; | ||
} | ||
|
||
double NewReleasePrice::getCharge(int daysRented) | ||
{ | ||
double result = daysRented * 3; | ||
return result; | ||
} | ||
|
||
int RegularPrice::getPriceCode() | ||
{ | ||
return Movie::REGULAR; | ||
} | ||
|
||
double RegularPrice::getCharge(int daysRented) | ||
{ | ||
double result = 2; | ||
if(daysRented > 2) | ||
result += (daysRented - 2) * 1.5; | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef PRICE_H | ||
#define PRICE_H | ||
|
||
#include "movie.h" | ||
|
||
class Price | ||
{ | ||
public: | ||
virtual int getPriceCode() = 0; | ||
virtual double getCharge(int daysRented) = 0; | ||
}; | ||
|
||
class ChildrensPrice : public Price | ||
{ | ||
int getPriceCode(); | ||
double getCharge(int daysRented); | ||
}; | ||
|
||
class NewReleasePrice : public Price | ||
{ | ||
int getPriceCode(); | ||
double getCharge(int daysRented); | ||
}; | ||
|
||
class RegularPrice : public Price | ||
{ | ||
int getPriceCode(); | ||
double getCharge(int daysRented); | ||
}; | ||
|
||
#endif // PRICE_H |