-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shop.cpp
45 lines (39 loc) · 1.14 KB
/
Shop.cpp
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
#include <iostream>
#include "Shop.h"
#include "SaleableItem.h"
#include "Book.h"
#include "CD.h"
#include "DVD.h"
#include <vector>
using namespace std;
void Shop::AddBook(const char* pTitle, unsigned int unitPricePence,
unsigned int noOfPages)
{
Book *book = new Book(pTitle, unitPricePence, noOfPages);
shared_ptr<SaleableItem> pSaleableItem(book);
saleableItems_.push_back(pSaleableItem);
}
void Shop::AddDVD(const char* pTitle, unsigned int unitPricePence,
unsigned int runningTimeMins,
DVD::DVDFormat format)
{
DVD *dvd = new DVD(pTitle, unitPricePence, runningTimeMins, format);
shared_ptr<SaleableItem> pSaleableItem(dvd);
saleableItems_.push_back(pSaleableItem);
}
void Shop::AddCD(const char* pTitle, unsigned int unitPricePence,
unsigned int runningTimeMins,
unsigned int noOfTracks)
{
CD *cd = new CD(pTitle, unitPricePence, runningTimeMins, noOfTracks);
shared_ptr<SaleableItem> pSaleableItem(cd);
saleableItems_.push_back(pSaleableItem);
}
void Shop::ShowTaxedPrices() const
{
for( auto& item : saleableItems_ )
{
cout << item->getTitle() << ": " << item->getNewPrice() <<
" pence" << endl;
}
}