Skip to content

Commit

Permalink
refactor 15.30
Browse files Browse the repository at this point in the history
  • Loading branch information
pezy committed Jun 12, 2015
1 parent 0b603ea commit 025a1f1
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 385 deletions.
6 changes: 6 additions & 0 deletions ch15/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,9 @@ Because derived objects are "sliced down" when assigned to a base-type object. T
If we want to holds objects related by inheritance, we should define the `vector` to hold pointers(preferable smart pointers) to the base class. So, the `vector` contains are dynamic type of the objects.

Different from previous program, it can be found that 20% and 50% discount has been applied to the total price calculation.

## Exercise 15.30:
> Write your own version of the `Basket` class and use it to compute prices for the same transactions as you used in the previous exercises.
- [Basket](ex15_30_Basket.h)
- [Quote & Bulk_quote](ex15_30_Quote_Bulk_quote.h)
12 changes: 12 additions & 0 deletions ch15/TEST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ex15_26_Quote.h"
#include "ex15_26_Bulk_quote.h"
#include "ex15_27_Bulk_quote.h"
#include "ex15_30_Basket.h"

int main()
{
Expand Down Expand Up @@ -118,4 +119,15 @@ int main()
cout << "\n===== ex27 =====" << endl;
EX27::Bulk_quote bulk_quote_27("0-201-82470-1", 50, 5, .19);
EX03::print_total(std::cout, bulk_quote_15, 6);

cout << "\n===== ex30 =====" << endl;
EX30::Basket bsk;

for (size_t i = 0; i != 10; ++i) {
bsk.add_item(EX30::Bulk_quote("Bible", 20.5, 5, 0.2));
bsk.add_item(EX30::Bulk_quote("CppPrimer", 30.5, 10, 0.5));
bsk.add_item(EX30::Quote("CLRS", 40.5));
}

bsk.total_receipt(std::cout);
}
18 changes: 0 additions & 18 deletions ch15/ex15.30/basket.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions ch15/ex15.30/basket.h

This file was deleted.

13 changes: 0 additions & 13 deletions ch15/ex15.30/bulk_quote.cpp

This file was deleted.

66 changes: 0 additions & 66 deletions ch15/ex15.30/bulk_quote.h

This file was deleted.

2 changes: 0 additions & 2 deletions ch15/ex15.30/disc_quote.cpp

This file was deleted.

79 changes: 0 additions & 79 deletions ch15/ex15.30/disc_quote.h

This file was deleted.

9 changes: 0 additions & 9 deletions ch15/ex15.30/limit_quote.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions ch15/ex15.30/limit_quote.h

This file was deleted.

46 changes: 0 additions & 46 deletions ch15/ex15.30/main.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions ch15/ex15.30/quote.cpp

This file was deleted.

Loading

0 comments on commit 025a1f1

Please sign in to comment.