From e33e2d817f097a6f4361d8c1834301ca7065418a Mon Sep 17 00:00:00 2001 From: pezy Date: Thu, 29 Jun 2017 00:17:48 +0800 Subject: [PATCH] finished 17.1 --- ch02/README.md | 2 +- ch02/ex2_42_1.cpp | 3 +- ch02/ex2_42_2.cpp | 3 +- ch02/ex2_42_3.cpp | 3 +- ch02/{ex2_42.h => ex2_42_sales_data.h} | 5 +- ch07/README.md | 20 ++++-- ch07/ex7_01.cpp | 37 ++-------- ch07/{ex7_02.h => ex7_02_sales_data.h} | 9 +-- ch07/ex7_03.cpp | 11 +-- ch07/{ex7_06.h => ex7_06_sales_data.h} | 13 +--- ch07/ex7_07.cpp | 10 +-- ch07/{ex7_11.cpp => ex7_11_sales_data.cpp} | 12 +--- ch07/{ex7_11.h => ex7_11_sales_data.h} | 13 +--- ch07/{ex7_12.h => ex7_12_sales_data.h} | 12 +--- ch07/ex7_13.cpp | 10 +-- ch07/{ex7_21.h => ex7_21_sales_data.h} | 11 +-- ch07/{ex7_26.cpp => ex7_26_sales_data.cpp} | 12 +--- ch07/{ex7_26.h => ex7_26_sales_data.h} | 13 +--- ch07/{ex7_41.cpp => ex7_41_sales_data.cpp} | 12 +--- ch07/{ex7_41.h => ex7_41_sales_data.h} | 16 +---- ...41_TEST.cpp => ex7_41_sales_data_test.cpp} | 10 +-- ch08/ex8_06.cpp | 37 +++------- ch08/ex8_07.cpp | 34 ++------- ch08/ex8_08.cpp | 33 ++------- ch10/ex10_12.cpp | 23 ++---- ch10/ex10_17.cpp | 20 ++---- ch11/ex11_11.cpp | 11 +-- ch14/README.md | 16 ++--- ch14/{ex14_02.cpp => ex14_02_sales_data.cpp} | 12 +--- ch14/{ex14_02.h => ex14_02_sales_data.h} | 13 +--- ...2_TEST.cpp => ex14_02_sales_data_test.cpp} | 2 +- ch14/{ex14_45.cpp => ex14_22_sales_data.cpp} | 2 +- ch14/{ex14_45.h => ex14_22_sales_data.h} | 27 ++----- ...2_TEST.cpp => ex14_22_sales_data_test.cpp} | 2 +- ch14/{ex14_22.cpp => ex14_45_sales_data.cpp} | 2 +- ch14/{ex14_22.h => ex14_45_sales_data.h} | 24 ++----- ...5_TEST.cpp => ex14_45_sales_data_test.cpp} | 2 +- ch17/README.md | 33 ++++++++- ch17/ex17_04_findBook.h | 59 ++++++++++++++++ ch17/ex17_05_findBook.h | 60 ++++++++++++++++ ch17/ex17_06_findBook.h | 70 +++++++++++++++++++ ch17/ex17_findBook_test.cpp | 54 ++++++++++++++ data/store1 | 10 +++ data/store2 | 8 +++ data/store3 | 10 +++ data/store4 | 10 +++ 46 files changed, 435 insertions(+), 376 deletions(-) rename ch02/{ex2_42.h => ex2_42_sales_data.h} (98%) rename ch07/{ex7_02.h => ex7_02_sales_data.h} (76%) rename ch07/{ex7_06.h => ex7_06_sales_data.h} (88%) rename ch07/{ex7_11.cpp => ex7_11_sales_data.cpp} (67%) rename ch07/{ex7_11.h => ex7_11_sales_data.h} (90%) rename ch07/{ex7_12.h => ex7_12_sales_data.h} (91%) rename ch07/{ex7_21.h => ex7_21_sales_data.h} (92%) rename ch07/{ex7_26.cpp => ex7_26_sales_data.cpp} (75%) rename ch07/{ex7_26.h => ex7_26_sales_data.h} (85%) rename ch07/{ex7_41.cpp => ex7_41_sales_data.cpp} (79%) rename ch07/{ex7_41.h => ex7_41_sales_data.h} (82%) rename ch07/{ex7_41_TEST.cpp => ex7_41_sales_data_test.cpp} (87%) rename ch14/{ex14_02.cpp => ex14_02_sales_data.cpp} (79%) rename ch14/{ex14_02.h => ex14_02_sales_data.h} (85%) rename ch14/{ex14_02_TEST.cpp => ex14_02_sales_data_test.cpp} (74%) rename ch14/{ex14_45.cpp => ex14_22_sales_data.cpp} (96%) rename ch14/{ex14_45.h => ex14_22_sales_data.h} (65%) rename ch14/{ex14_22_TEST.cpp => ex14_22_sales_data_test.cpp} (79%) rename ch14/{ex14_22.cpp => ex14_45_sales_data.cpp} (96%) rename ch14/{ex14_22.h => ex14_45_sales_data.h} (73%) rename ch14/{ex14_45_TEST.cpp => ex14_45_sales_data_test.cpp} (87%) create mode 100644 ch17/ex17_04_findBook.h create mode 100644 ch17/ex17_05_findBook.h create mode 100644 ch17/ex17_06_findBook.h create mode 100644 ch17/ex17_findBook_test.cpp create mode 100644 data/store1 create mode 100644 data/store2 create mode 100644 data/store3 create mode 100644 data/store4 diff --git a/ch02/README.md b/ch02/README.md index e44fdea8..f467990b 100644 --- a/ch02/README.md +++ b/ch02/README.md @@ -721,7 +721,7 @@ int main() > Write your own version of the `Sales_data.h` header and use it to rewrite the ## Exercise from 2.6.2(p. 76) -- [Sales_data.h](ex2_42.h) +- [Sales_data.h](ex2_42_sales_data.h) - [1.5.1.](ex2_42_1.cpp) - [1.5.2.](ex2_42_2.cpp) - [1.6.](ex2_42_3.cpp) diff --git a/ch02/ex2_42_1.cpp b/ch02/ex2_42_1.cpp index 21511315..3099476f 100644 --- a/ch02/ex2_42_1.cpp +++ b/ch02/ex2_42_1.cpp @@ -1,5 +1,6 @@ #include -#include "ex2_42.h" + +#include "ex2_42_sales_data.h" int main() { diff --git a/ch02/ex2_42_2.cpp b/ch02/ex2_42_2.cpp index 161e14f8..99eb7e44 100644 --- a/ch02/ex2_42_2.cpp +++ b/ch02/ex2_42_2.cpp @@ -1,5 +1,6 @@ #include -#include "ex2_42.h" + +#include "ex2_42_sales_data.h" int main() { diff --git a/ch02/ex2_42_3.cpp b/ch02/ex2_42_3.cpp index e50a281f..27e9d930 100644 --- a/ch02/ex2_42_3.cpp +++ b/ch02/ex2_42_3.cpp @@ -1,5 +1,6 @@ #include -#include "ex2_42.h" + +#include "ex2_42_sales_data.h" int main() { diff --git a/ch02/ex2_42.h b/ch02/ex2_42_sales_data.h similarity index 98% rename from ch02/ex2_42.h rename to ch02/ex2_42_sales_data.h index b394b402..e954abd0 100644 --- a/ch02/ex2_42.h +++ b/ch02/ex2_42_sales_data.h @@ -1,6 +1,7 @@ -#include #include +#include +// own Sales_data struct Sales_data { std::string bookNo; unsigned units_sold = 0; @@ -48,4 +49,4 @@ void Sales_data::Print() std::cout << averagePrice << std::endl; else std::cout << "(no sales)" << std::endl; -} +} \ No newline at end of file diff --git a/ch07/README.md b/ch07/README.md index 91998fad..d52ea8be 100644 --- a/ch07/README.md +++ b/ch07/README.md @@ -2,7 +2,7 @@ ## [Exercise 7.1](ex7_01.cpp) -## [Exercise 7.2](ex7_02.h) +## [Exercise 7.2](ex7_02_sales_data.h) ## [Exercise 7.3](ex7_03.cpp) @@ -10,7 +10,7 @@ ## [Exercise 7.5](ex7_05.h) -## [Exercise 7.6](ex7_06.h) +## [Exercise 7.6](ex7_06_sales_data.h) ## [Exercise 7.7](ex7_07.cpp) @@ -38,9 +38,11 @@ if (secondStep) the condition of the `if` statement would read two `Sales_data` object at one time. -## Exercise 7.11 [Header](ex7_11.h)|[CPP](ex7_11.cpp) +## Exercise 7.11 -## [Exercise 7.12](ex7_12.h) +[Sales_data Definition](ex7_11_sales_data.h) | [Sales_data Implementation](ex7_11_sales_data.cpp) + +## [Exercise 7.12](ex7_12_sales_data.h) ## [Exercise 7.13](ex7_13.cpp) @@ -97,7 +99,7 @@ the interface should be defined as public, the data shouldn't expose to outside - lessens encapsulation and therefore maintainability. - code verbosity, declarations inside the class, outside the class. -## [Exercise 7.21](ex7_21.h) +## [Exercise 7.21](ex7_21_sales_data.h) ## [Exercise 7.22](ex7_22.h) @@ -115,7 +117,9 @@ The class below can rely on it. It goes in *Section 7.1.5*: Hence the class below which used only built-in type and strings can rely on the default version of copy and assignment. (by [@Mooophy](https://github.com/Mooophy)\) -## Exercise 7.26 [Header](ex7_26.h)|[CPP](ex7_26.cpp) +## Exercise 7.26 + +[Sales_data Definition](ex7_26_sales_data.h) | [Sales_data Implementation](ex7_26_sales_data.cpp) ## Exercise 7.27 [Class](ex7_27.h)|[Test](ex7_27_TEST.cpp) @@ -279,7 +283,9 @@ private: }; ``` -## Exercise 7.41 [Header](ex7_41.h)|[CPP](ex7_41.cpp)|[Test](ex7_41_TEST.cpp) +## Exercise 7.41 + +[Sales_data Definition](ex7_41_sales_data.h) | [Sales_data Implementation](ex7_41_sales_data.cpp)|[Sales_data Test](ex7_41_sales_data_test.cpp) ## Exercise 7.42 diff --git a/ch07/ex7_01.cpp b/ch07/ex7_01.cpp index ff1c8ab8..6f8ba268 100644 --- a/ch07/ex7_01.cpp +++ b/ch07/ex7_01.cpp @@ -1,42 +1,19 @@ -// -// ex7_01.cpp -// Exercise 7.1 -// -// Created by pezy on 14/10/30. -// Copyright (c) 2014 pezy. All rights reserved. -// - -#include -#include -using std::cin; -using std::cout; -using std::endl; -using std::string; - -struct Sales_data { - string bookNo; - unsigned units_sold = 0; - double revenue = 0.0; -}; +#include "../ch02/ex2_42_sales_data.h" int main() { Sales_data total; - if (cin >> total.bookNo >> total.units_sold >> total.revenue) { + if (std::cin >> total.bookNo >> total.units_sold >> total.revenue) { Sales_data trans; - while (cin >> trans.bookNo >> trans.units_sold >> trans.revenue) { - if (total.bookNo == trans.bookNo) { - total.units_sold += trans.units_sold; - total.revenue += trans.revenue; - } + while (std::cin >> trans.bookNo >> trans.units_sold >> trans.revenue) { + if (total.bookNo == trans.bookNo) + total.AddData(trans); else { - cout << total.bookNo << " " << total.units_sold << " " - << total.revenue << endl; + total.Print(); total = trans; } } - cout << total.bookNo << " " << total.units_sold << " " << total.revenue - << endl; + total.Print(); } else { std::cerr << "No data?!" << std::endl; diff --git a/ch07/ex7_02.h b/ch07/ex7_02_sales_data.h similarity index 76% rename from ch07/ex7_02.h rename to ch07/ex7_02_sales_data.h index f0ffa35d..389b1c24 100644 --- a/ch07/ex7_02.h +++ b/ch07/ex7_02_sales_data.h @@ -1,16 +1,9 @@ -// -// ex7_02.h -// Exercise 7.2 -// -// Created by pezy on 14/11/8. -// Copyright (c) 2014 pezy. All rights reserved. -// - #ifndef CP5_ex7_02_h #define CP5_ex7_02_h #include +// Add the combine and isbn members to the Sales_data struct Sales_data { std::string isbn() const { return bookNo; }; Sales_data& combine(const Sales_data&); diff --git a/ch07/ex7_03.cpp b/ch07/ex7_03.cpp index 6e5802e7..1f3e38bd 100644 --- a/ch07/ex7_03.cpp +++ b/ch07/ex7_03.cpp @@ -1,13 +1,6 @@ -// -// ex7_03.cpp -// Exercise 7.03 -// -// Created by pezy on 14/11/8. -// Copyright (c) 2014 pezy. All rights reserved. -// - -#include "ex7_02.h" +#include "ex7_02_sales_data.h" #include + using std::cin; using std::cout; using std::endl; diff --git a/ch07/ex7_06.h b/ch07/ex7_06_sales_data.h similarity index 88% rename from ch07/ex7_06.h rename to ch07/ex7_06_sales_data.h index 0a4eb316..fcb22e5a 100644 --- a/ch07/ex7_06.h +++ b/ch07/ex7_06_sales_data.h @@ -1,17 +1,10 @@ -// -// ex7_06.h -// Exercise 7.6 -// -// Created by pezy on 11/8/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - #ifndef CP5_ex7_06_h #define CP5_ex7_06_h -#include #include +#include +// added add, read, print functions struct Sales_data { std::string const& isbn() const { return bookNo; }; Sales_data& combine(const Sales_data&); @@ -51,4 +44,4 @@ Sales_data add(const Sales_data& lhs, const Sales_data& rhs) return sum; } -#endif +#endif \ No newline at end of file diff --git a/ch07/ex7_07.cpp b/ch07/ex7_07.cpp index e9c057d3..1833fe06 100644 --- a/ch07/ex7_07.cpp +++ b/ch07/ex7_07.cpp @@ -1,12 +1,4 @@ -// -// ex7_07.cpp -// Exercise 7.7 -// -// Created by pezy on 11/8/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - -#include "ex7_06.h" +#include "ex7_06_sales_data.h" int main() { diff --git a/ch07/ex7_11.cpp b/ch07/ex7_11_sales_data.cpp similarity index 67% rename from ch07/ex7_11.cpp rename to ch07/ex7_11_sales_data.cpp index 43666bce..b7ab574f 100644 --- a/ch07/ex7_11.cpp +++ b/ch07/ex7_11_sales_data.cpp @@ -1,12 +1,4 @@ -// -// ex7_11.cpp -// Exercise 7.11 -// -// Created by pezy on 11/9/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - -#include "ex7_11.h" +#include "ex7_11_sales_data.h" int main() { @@ -21,6 +13,4 @@ int main() Sales_data item4(std::cin); print(std::cout, item4) << std::endl; - - return 0; } diff --git a/ch07/ex7_11.h b/ch07/ex7_11_sales_data.h similarity index 90% rename from ch07/ex7_11.h rename to ch07/ex7_11_sales_data.h index 8c221d49..c43b538f 100644 --- a/ch07/ex7_11.h +++ b/ch07/ex7_11_sales_data.h @@ -1,17 +1,10 @@ -// -// ex7_11.h -// Exercise 7.11 -// -// Created by pezy on 11/9/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - #ifndef CP5_ex7_11_h #define CP5_ex7_11_h -#include #include +#include +// Add constructors to your Sales_data class struct Sales_data { Sales_data() = default; Sales_data(const std::string& s) : bookNo(s) {} @@ -64,4 +57,4 @@ Sales_data& Sales_data::combine(const Sales_data& rhs) return *this; } -#endif +#endif \ No newline at end of file diff --git a/ch07/ex7_12.h b/ch07/ex7_12_sales_data.h similarity index 91% rename from ch07/ex7_12.h rename to ch07/ex7_12_sales_data.h index b659c9a6..992c6835 100644 --- a/ch07/ex7_12.h +++ b/ch07/ex7_12_sales_data.h @@ -1,20 +1,14 @@ -// -// ex7_12.h -// Exercise 7.12 -// -// Created by pezy on 11/9/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - #ifndef CP5_ex7_12_h #define CP5_ex7_12_h -#include #include +#include struct Sales_data; std::istream& read(std::istream&, Sales_data&); +// Move the definition of the Sales_data constructor that takes an istream into +// the body of the Sales_data class. struct Sales_data { Sales_data() = default; Sales_data(const std::string& s) : bookNo(s) {} diff --git a/ch07/ex7_13.cpp b/ch07/ex7_13.cpp index 71020e30..c1f6ab68 100644 --- a/ch07/ex7_13.cpp +++ b/ch07/ex7_13.cpp @@ -1,12 +1,4 @@ -// -// ex7_13.cpp -// Exercise 7.13 -// -// Created by pezy on 11/9/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - -#include "ex7_12.h" +#include "ex7_12_sales_data.h" int main() { diff --git a/ch07/ex7_21.h b/ch07/ex7_21_sales_data.h similarity index 92% rename from ch07/ex7_21.h rename to ch07/ex7_21_sales_data.h index 1acc7cb8..ef0116f8 100644 --- a/ch07/ex7_21.h +++ b/ch07/ex7_21_sales_data.h @@ -1,17 +1,10 @@ -// -// ex7_21.h -// Exercise 7.21 -// -// Created by pezy on 11/13/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - #ifndef CP5_ex7_21_h #define CP5_ex7_21_h -#include #include +#include +// Update Sales_data class to hide its implementation class Sales_data { friend std::istream& read(std::istream& is, Sales_data& item); friend std::ostream& print(std::ostream& os, const Sales_data& item); diff --git a/ch07/ex7_26.cpp b/ch07/ex7_26_sales_data.cpp similarity index 75% rename from ch07/ex7_26.cpp rename to ch07/ex7_26_sales_data.cpp index e4947b7a..c03b3591 100644 --- a/ch07/ex7_26.cpp +++ b/ch07/ex7_26_sales_data.cpp @@ -1,14 +1,4 @@ -// -// ex7_26.cpp -// Exercise 7.26 -// -// Created by pezy on 11/9/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @Brief implementation of class Sales_data -// @See ex7_26.h - -#include "ex7_26.h" +#include "ex7_26_sales_data.h" // member functions. Sales_data& Sales_data::combine(const Sales_data& rhs) diff --git a/ch07/ex7_26.h b/ch07/ex7_26_sales_data.h similarity index 85% rename from ch07/ex7_26.h rename to ch07/ex7_26_sales_data.h index 71ccd186..25d45a47 100644 --- a/ch07/ex7_26.h +++ b/ch07/ex7_26_sales_data.h @@ -1,19 +1,10 @@ -// -// ex7_26.h -// Exercise 7.26 -// -// Created by pezy on 11/14/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @See ex7_21.h -// @Add inline member function "Sales_data::avg_pric" - #ifndef CP5_ex7_26_h #define CP5_ex7_26_h -#include #include +#include +// define Sales_data::avg_price as an inline function. class Sales_data { friend std::istream& read(std::istream& is, Sales_data& item); friend std::ostream& print(std::ostream& os, const Sales_data& item); diff --git a/ch07/ex7_41.cpp b/ch07/ex7_41_sales_data.cpp similarity index 79% rename from ch07/ex7_41.cpp rename to ch07/ex7_41_sales_data.cpp index e1ab63d5..ab0699f7 100644 --- a/ch07/ex7_41.cpp +++ b/ch07/ex7_41_sales_data.cpp @@ -1,14 +1,4 @@ -// -// ex7_41.cpp -// Exercise 7.41 -// -// Created by pezy on 11/20/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @Brief implementation of class Sales_data -// @See ex7_41.h - -#include "ex7_41.h" +#include "ex7_41_sales_data.h" // constructor Sales_data::Sales_data(std::istream& is) : Sales_data() diff --git a/ch07/ex7_41.h b/ch07/ex7_41_sales_data.h similarity index 82% rename from ch07/ex7_41.h rename to ch07/ex7_41_sales_data.h index 091b0c7a..69d34b16 100644 --- a/ch07/ex7_41.h +++ b/ch07/ex7_41_sales_data.h @@ -1,21 +1,11 @@ -// -// ex7_41.h -// Exercise 7.41 -// -// Created by pezy on 11/20/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @See ex7_26.h -// @Add 1. use delegating constructors -// 2. add a statement to the body of each of the constructors that prints -// a message whether it is executed. - #ifndef CP5_ex7_41_h #define CP5_ex7_41_h -#include #include +#include +// use delegating constructors, added a statement to the body of each of the +// constructors that prints a message whether it is executed class Sales_data { friend std::istream& read(std::istream& is, Sales_data& item); friend std::ostream& print(std::ostream& os, const Sales_data& item); diff --git a/ch07/ex7_41_TEST.cpp b/ch07/ex7_41_sales_data_test.cpp similarity index 87% rename from ch07/ex7_41_TEST.cpp rename to ch07/ex7_41_sales_data_test.cpp index 587388c6..f3c00e4e 100644 --- a/ch07/ex7_41_TEST.cpp +++ b/ch07/ex7_41_sales_data_test.cpp @@ -1,12 +1,4 @@ -// -// ex7_41_TEST.cpp -// Test of Exercise 7.41 -// -// Created by pezy on 11/14/14. -// Copyright (c) 2014 pezy. All rights reserved. -// - -#include "ex7_41.h" +#include "ex7_41_sales_data.h" using std::cout; using std::endl; diff --git a/ch08/ex8_06.cpp b/ch08/ex8_06.cpp index a9cd752a..d681dec2 100644 --- a/ch08/ex8_06.cpp +++ b/ch08/ex8_06.cpp @@ -1,30 +1,11 @@ -// -// ex8_06.cpp -// Exercise 8.6 -// -// Created by pezy on 11/27/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @Brief Rewrite the bookstore program from ¡ì7.1.1 (p.256) to read its -// transactions from a file. -// Pass the name of the file as an argument to main (¡ì6.2.5, p.218). -// @See ex7_26.h (use the Sales_data) -// @Run give a parameter: "../data/book.txt" -// @Output 0-201-78345-X 5 110 -// 0-201-78346-X 9 839.2 - #include #include -#include "../ch07/ex7_26.h" -using std::ifstream; -using std::cout; -using std::endl; -using std::cerr; +#include "../ch07/ex7_26_sales_data.h" int main(int argc, char** argv) { - ifstream input(argv[1]); + std::ifstream input(argv[1]); // use "../data/book.txt" Sales_data total; if (read(input, total)) { @@ -33,15 +14,19 @@ int main(int argc, char** argv) if (total.isbn() == trans.isbn()) total.combine(trans); else { - print(cout, total) << endl; + print(std::cout, total) << std::endl; total = trans; } } - print(cout, total) << endl; + print(std::cout, total) << std::endl; } else { - cerr << "No data?!" << endl; + std::cerr << "No data?!" << std::endl; } - - return 0; } + +/* + *! Output: + *! 0-201-78345-X 5 110 + *! 0-201-78346-X 9 839.2 + */ \ No newline at end of file diff --git a/ch08/ex8_07.cpp b/ch08/ex8_07.cpp index 33931659..f60fd68d 100644 --- a/ch08/ex8_07.cpp +++ b/ch08/ex8_07.cpp @@ -1,29 +1,11 @@ -// -// ex8_07.cpp -// Exercise 8.7 -// -// Created by pezy on 11/28/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @Brief Revise the bookstore program from the previous section to write its -// output to a file. -// Pass the name of that file as a second argument to main. -// @See ex8_06.cpp -// @Run give a parameter: "../data/book.txt ../data/out.txt" - #include -#include -#include "../ch07/ex7_26.h" -using std::ifstream; -using std::ofstream; -using std::endl; -using std::cerr; +#include "../ch07/ex7_26_sales_data.h" int main(int argc, char** argv) { - ifstream input(argv[1]); - ofstream output(argv[2]); + std::ifstream input(argv[1]); // "../data/book.txt" + std::ofstream output(argv[2]); // "../data/out.txt" Sales_data total; if (read(input, total)) { @@ -32,15 +14,13 @@ int main(int argc, char** argv) if (total.isbn() == trans.isbn()) total.combine(trans); else { - print(output, total) << endl; + print(output, total) << std::endl; total = trans; } } - print(output, total) << endl; + print(output, total) << std::endl; } else { - cerr << "No data?!" << endl; + std::cerr << "No data?!" << std::endl; } - - return 0; -} +} \ No newline at end of file diff --git a/ch08/ex8_08.cpp b/ch08/ex8_08.cpp index be1b1663..76524c12 100644 --- a/ch08/ex8_08.cpp +++ b/ch08/ex8_08.cpp @@ -1,30 +1,11 @@ -// -// ex8_08.cpp -// Exercise 8.8 -// -// Created by pezy on 11/28/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @Brief Revise the program from the previous exercise to append its output -// to its given file. -// Run the program on the same output file at least twice to ensure -// that the data are preserved -// @See ex8_07.cpp -// @Run give a parameter: "../data/book.txt ../data/out.txt" - #include -#include -#include "../ch07/ex7_26.h" -using std::ifstream; -using std::ofstream; -using std::endl; -using std::cerr; +#include "../ch07/ex7_26_sales_data.h" int main(int argc, char** argv) { - ifstream input(argv[1]); - ofstream output(argv[2], ofstream::app); + std::ifstream input(argv[1]); // "../data/book.txt" + std::ofstream output(argv[2], std::ofstream::app); // "../data/out.txt" Sales_data total; if (read(input, total)) { @@ -33,15 +14,13 @@ int main(int argc, char** argv) if (total.isbn() == trans.isbn()) total.combine(trans); else { - print(output, total) << endl; + print(output, total) << std::endl; total = trans; } } - print(output, total) << endl; + print(output, total) << std::endl; } else { - cerr << "No data?!" << endl; + std::cerr << "No data?!" << std::endl; } - - return 0; } diff --git a/ch10/ex10_12.cpp b/ch10/ex10_12.cpp index a06416a1..53198ae2 100644 --- a/ch10/ex10_12.cpp +++ b/ch10/ex10_12.cpp @@ -1,25 +1,18 @@ -//! @Yue Wang -//! Exercise 10.12: -//! Write a function named compareIsbn that compares the isbn() members of two -//! Sales_data objects. -//! Use that function to sort a vector that holds Sales_data objects. -//! - -#include -#include -#include #include #include -#include "../ch07/ex7_26.h" // Sales_data class. +#include -inline bool compareIsbn(const Sales_data& sd1, const Sales_data& sd2) +#include "../ch07/ex7_26_sales_data.h" // Sales_data class. + +bool compareIsbn(const Sales_data& sd1, const Sales_data& sd2) { - return sd1.isbn().size() < sd2.isbn().size(); + return sd1.isbn() < sd2.isbn(); } int main() { - Sales_data d1("aa"), d2("aaaa"), d3("aaa"), d4("z"), d5("aaaaz"); + Sales_data d1("CppPrimer"), d2("JavaCore"), d3("PythonCookBook"), + d4("CppCore"), d5("AwesomeCPP"); std::vector v{d1, d2, d3, d4, d5}; //! @note the elements the iterators pointing to @@ -28,6 +21,4 @@ int main() for (const auto& element : v) std::cout << element.isbn() << " "; std::cout << std::endl; - - return 0; } diff --git a/ch10/ex10_17.cpp b/ch10/ex10_17.cpp index ef6b9190..07c5e6f0 100644 --- a/ch10/ex10_17.cpp +++ b/ch10/ex10_17.cpp @@ -1,29 +1,19 @@ -//! @pezy -//! -//! Exercise 10.17 -//! Rewrite exercise 10.12 from 10.3.1 (p. 387) -//! to use a lambda in the call to sort instead of the compareIsbn function. -//! -//! @See 7.26, 10.12 - -#include "../ch07/ex7_26.h" // Sales_data class. #include -#include -#include #include +#include "../ch07/ex7_26_sales_data.h" // Sales_data class. + int main() { - Sales_data d1("aa"), d2("aaaa"), d3("aaa"), d4("z"), d5("aaaaz"); + Sales_data d1("CppPrimer"), d2("JavaCore"), d3("PythonCookBook"), + d4("CppCore"), d5("AwesomeCPP"); std::vector v{d1, d2, d3, d4, d5}; std::sort(v.begin(), v.end(), [](const Sales_data& sd1, const Sales_data& sd2) { - return sd1.isbn().size() < sd2.isbn().size(); + return sd1.isbn() < sd2.isbn(); }); for (const auto& element : v) std::cout << element.isbn() << " "; std::cout << std::endl; - - return 0; } diff --git a/ch11/ex11_11.cpp b/ch11/ex11_11.cpp index ffabddc3..7c0daeef 100644 --- a/ch11/ex11_11.cpp +++ b/ch11/ex11_11.cpp @@ -1,13 +1,4 @@ -// -// ex11_11.cpp -// Exercise 11.11 -// -// Created by pezy on 12/15/14. -// Copyright (c) 2014 pezy. All rights reserved. -// -// Redefine bookstore without using decltype. - -#include "../ch07/ex7_26.h" +#include "../ch07/ex7_26_sales_data.h" #include bool compareIsbn(const Sales_data& lhs, const Sales_data& rhs) diff --git a/ch14/README.md b/ch14/README.md index bc35a397..ada79ae4 100644 --- a/ch14/README.md +++ b/ch14/README.md @@ -19,7 +19,7 @@ Same: >Write declarations for the overloaded input, output, addition, and compound-assignment operators for `Sales_data`. -[hpp](ex14_02.h) | [cpp](ex14_02.cpp) +[Sales_data Definition](ex14_02_sales_data.h) | [Sales_data Implementation](ex14_02_sales_data.cpp) | [Sales_data Test](ex14_02_sales_data_test.cpp) ## Exercise 14.3 @@ -60,9 +60,9 @@ Reference: (e) non-member -(f) symetric , non-member +(f) symmetric , non-member -(g) symetric , non-member +(g) symmetric , non-member (h) = () [] -> must be member @@ -100,13 +100,13 @@ see [Exercise 14.2](#exercise-142). ## Exercise 14.10 ->Describe the behaviour of the Sales_data input operator if given the following input: +>Describe the behavior of the Sales_data input operator if given the following input: - (a) 0-201-99999-9 10 24.95 - (b) 10 24.95 0-210-99999-9 - (a) correct format. -- (b) ilegal input. But `0-210-99999-9` will be converted to a float stored in this object. As a result, the data inside will be a wrong one. +- (b) illegal input. But `0-210-99999-9` will be converted to a float stored in this object. As a result, the data inside will be a wrong one. Output: `10 24 22.8 0.95` @@ -126,7 +126,7 @@ istream& operator>>(istream& in, Sales_data& s) } ``` -no input check. nothing happend. +no input check. nothing happened. ## Exercise 14.12 @@ -213,7 +213,7 @@ Sales_data operator+(const Sales_data &lhs, const Sales_data &rhs) >Define a version of the assignment operator that can assign a `string` representing an ISBN to a `Sales_data`. -[hpp](ex14_22.h) | [cpp](ex14_22.cpp) | [Test](ex14_22_TEST.cpp) +[Sales_data Definition](ex14_22_sales_data.h) | [Sales_data Implementation](ex14_22_sales_data.cpp) | [Sales_data Test](ex14_22_sales_data_test.cpp) ## Exercise 14.23 @@ -370,7 +370,7 @@ std::transform(ivec.begin(), ivec.end(), ivec.begin(), std::bind(std::multiplies > Write conversion operators to convert a `Sales_data` to `string` and to `double`. What values do you think these operators should return? -[hpp](ex14_45.h) | [cpp](ex14_45.cpp) | [Test](ex14_45_TEST.cpp) +[Sales_data Definition](ex14_45_sales_data.h) | [Sales_data Implementation](ex14_45_sales_data.cpp) | [Sales_data Test](ex14_45_sales_data_test.cpp) ## Exercise 14.46 diff --git a/ch14/ex14_02.cpp b/ch14/ex14_02_sales_data.cpp similarity index 79% rename from ch14/ex14_02.cpp rename to ch14/ex14_02_sales_data.cpp index 1e99bf53..dea29b12 100644 --- a/ch14/ex14_02.cpp +++ b/ch14/ex14_02_sales_data.cpp @@ -1,14 +1,4 @@ -// -// ex14_02.cpp -// Exercise 14.2 -// -// Created by pezy on 3/9/15. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @Brief implementation of class Sales_data -// @See ex14_02.h - -#include "ex14_02.h" +#include "ex14_02_sales_data.h" Sales_data::Sales_data(std::istream& is) : Sales_data() { diff --git a/ch14/ex14_02.h b/ch14/ex14_02_sales_data.h similarity index 85% rename from ch14/ex14_02.h rename to ch14/ex14_02_sales_data.h index e7320318..7c7ae23e 100644 --- a/ch14/ex14_02.h +++ b/ch14/ex14_02_sales_data.h @@ -1,19 +1,10 @@ -// -// ex14_02.h -// Exercise 14.2 -// -// Created by pezy on 3/9/15. -// Copyright (c) 2014 pezy. All rights reserved. -// -// @See ex7_41.h -// @Add overloaded input, output, addition, and compound-assignment operators - #ifndef CP5_ex14_02_h #define CP5_ex14_02_h -#include #include +#include +// added overloaded input, output, addition, and compound-assignment operators class Sales_data { friend std::istream& operator>>(std::istream&, Sales_data&); // input friend std::ostream& operator<<(std::ostream&, const Sales_data&); // output diff --git a/ch14/ex14_02_TEST.cpp b/ch14/ex14_02_sales_data_test.cpp similarity index 74% rename from ch14/ex14_02_TEST.cpp rename to ch14/ex14_02_sales_data_test.cpp index 01fa2da9..e764fee5 100644 --- a/ch14/ex14_02_TEST.cpp +++ b/ch14/ex14_02_sales_data_test.cpp @@ -1,4 +1,4 @@ -#include "ex14_02.h" +#include "ex14_02_sales_data.h" int main() { diff --git a/ch14/ex14_45.cpp b/ch14/ex14_22_sales_data.cpp similarity index 96% rename from ch14/ex14_45.cpp rename to ch14/ex14_22_sales_data.cpp index 40d502d1..8d454967 100644 --- a/ch14/ex14_45.cpp +++ b/ch14/ex14_22_sales_data.cpp @@ -1,4 +1,4 @@ -#include "ex14_45.h" +#include "ex14_22_sales_data.h" Sales_data::Sales_data(std::istream& is) : Sales_data() { diff --git a/ch14/ex14_45.h b/ch14/ex14_22_sales_data.h similarity index 65% rename from ch14/ex14_45.h rename to ch14/ex14_22_sales_data.h index 50c4de8e..17afea68 100644 --- a/ch14/ex14_45.h +++ b/ch14/ex14_22_sales_data.h @@ -1,22 +1,11 @@ -/* -================================================================================= +#ifndef CP5_ex14_22_h +#define CP5_ex14_22_h -C++ Primer 5th Exercise Answer Source Code -Copyright (C) 2014-2015 github.com/pezy/Cpp-Primer - -Sales_data - -If you have questions, try to connect with me: pezy - -================================================================================= -*/ - -#ifndef CP5_ex14_45_h -#define CP5_ex14_45_h - -#include #include +#include +// added an assignment operator that can assign a string representing an ISBN to +// a Sales_data class Sales_data { friend std::istream& operator>>(std::istream&, Sales_data&); friend std::ostream& operator<<(std::ostream&, const Sales_data&); @@ -31,11 +20,9 @@ class Sales_data { Sales_data(const std::string& s) : Sales_data(s, 0, 0.0f) {} Sales_data(std::istream& is); - Sales_data& operator=(const std::string&); - Sales_data& operator+=(const Sales_data&); - explicit operator std::string() const { return bookNo; } - explicit operator double() const { return avg_price(); } + Sales_data& operator=(const std::string&); // assign string to Sales_data + Sales_data& operator+=(const Sales_data&); std::string isbn() const { return bookNo; } private: diff --git a/ch14/ex14_22_TEST.cpp b/ch14/ex14_22_sales_data_test.cpp similarity index 79% rename from ch14/ex14_22_TEST.cpp rename to ch14/ex14_22_sales_data_test.cpp index 88ee3eff..06608628 100644 --- a/ch14/ex14_22_TEST.cpp +++ b/ch14/ex14_22_sales_data_test.cpp @@ -1,4 +1,4 @@ -#include "ex14_22.h" +#include "ex14_22_sales_data.h" int main() { diff --git a/ch14/ex14_22.cpp b/ch14/ex14_45_sales_data.cpp similarity index 96% rename from ch14/ex14_22.cpp rename to ch14/ex14_45_sales_data.cpp index dc5d3f75..673efa68 100644 --- a/ch14/ex14_22.cpp +++ b/ch14/ex14_45_sales_data.cpp @@ -1,4 +1,4 @@ -#include "ex14_22.h" +#include "ex14_45_sales_data.h" Sales_data::Sales_data(std::istream& is) : Sales_data() { diff --git a/ch14/ex14_22.h b/ch14/ex14_45_sales_data.h similarity index 73% rename from ch14/ex14_22.h rename to ch14/ex14_45_sales_data.h index 9b44f808..58c5b412 100644 --- a/ch14/ex14_22.h +++ b/ch14/ex14_45_sales_data.h @@ -1,22 +1,10 @@ -/* -================================================================================= +#ifndef CP5_ex14_45_h +#define CP5_ex14_45_h -C++ Primer 5th Exercise Answer Source Code -Copyright (C) 2014-2015 github.com/pezy/Cpp-Primer - -Sales_data - -If you have questions, try to connect with me: pezy - -================================================================================= -*/ - -#ifndef CP5_ex14_22_h -#define CP5_ex14_22_h - -#include #include +#include +// added conversion operators to convert a Sales_data to string and to double. class Sales_data { friend std::istream& operator>>(std::istream&, Sales_data&); friend std::ostream& operator<<(std::ostream&, const Sales_data&); @@ -32,8 +20,10 @@ class Sales_data { Sales_data(std::istream& is); Sales_data& operator=(const std::string&); - Sales_data& operator+=(const Sales_data&); + explicit operator std::string() const { return bookNo; } // to string + explicit operator double() const { return avg_price(); } // to double + std::string isbn() const { return bookNo; } private: diff --git a/ch14/ex14_45_TEST.cpp b/ch14/ex14_45_sales_data_test.cpp similarity index 87% rename from ch14/ex14_45_TEST.cpp rename to ch14/ex14_45_sales_data_test.cpp index 8d09b990..fdec6f50 100644 --- a/ch14/ex14_45_TEST.cpp +++ b/ch14/ex14_45_sales_data_test.cpp @@ -1,4 +1,4 @@ -#include "ex14_45.h" +#include "ex14_45_sales_data.h" int main() { diff --git a/ch17/README.md b/ch17/README.md index e211fc39..f1c7c584 100644 --- a/ch17/README.md +++ b/ch17/README.md @@ -21,4 +21,35 @@ tuple, std::pair t; > Rewrite the `TextQuery` programs from 12.3 (p. 484) to use a `tuple` instead of the `QueryResult` class. Explain which design you think is better and why. -[TextQuery Definition](ex17_03_text_query.h) | [TextQuery Implementation](ex17_03_text_query.cpp) | [TextQuery Test](ex17_03_text_query_test.cpp) \ No newline at end of file +[TextQuery Definition](ex17_03_text_query.h) | [TextQuery Implementation](ex17_03_text_query.cpp) | [TextQuery Test](ex17_03_text_query_test.cpp) + +## Exercise 17.4 + +> Write and test your own version of the `findBook` function. + +[`findBook` function by tuple way](ex17_04_findBook.h) | [`findBook` Test](ex17_findBook_test.cpp) + +## Exercise 17.5 + +> Rewrite `findBook` to return a pair that holds an index and a pair of iterators. + +[`findBook` function by pair way](ex17_05_findBook.h) | [`findBook` Test](ex17_findBook_test.cpp) + +## Exercise 17.6 + +> Rewrite `findBook` so that it does not use tuple or pair. + +[`findBook` function without tuple or pair](ex17_06_findBook.h) | [`findBook` Test](ex17_findBook_test.cpp) + +## Exercise 17.7 + +> Explain which version of `findBook` you prefer and why. + +I prefer the tuple version, because this version is the most refined. + +## Exercise 17.8 + +> What would happen if we passed `Sales_data()` as the third parameter to accumulate in the last code example in this section? + +Nothing happened, it's the same as passed `Sales_data(s)`. +Because `std::accumulate`'s third parameter is the initial value of the sum. It's will be zero whether `Sales_data()` or `Sales_data(s)`. Check the constructor of `Sales_data` and the `operator+=` member for more information. \ No newline at end of file diff --git a/ch17/ex17_04_findBook.h b/ch17/ex17_04_findBook.h new file mode 100644 index 00000000..ddd89585 --- /dev/null +++ b/ch17/ex17_04_findBook.h @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include +#include + +#include "../ch14/ex14_45_sales_data.h" + +using std::tuple; +using std::vector; +using std::string; +using std::get; + +namespace EX04 { +using matches = + tuple::size_type, vector::const_iterator, + vector::const_iterator>; + +vector findBook(const vector>& files, + const string& book) +{ + vector ret; // initally empty + // for each store find the range of matching books, if any + for (auto it = files.cbegin(); it != files.cend(); ++it) { + // find the range of Sales_data that have the same ISBN + auto found = + std::equal_range(it->cbegin(), it->cend(), Sales_data(book), + [](const Sales_data& sd1, const Sales_data& sd2) { + return sd1.isbn() < sd2.isbn(); + }); + if (found.first != found.second) // this store had sales + // remember the index of this store and the matching range + ret.push_back( + make_tuple(it - files.cbegin(), found.first, found.second)); + } + return ret; // empty if no matches found +} + +void reportResults(std::istream& in, std::ostream& os, + const vector>& files) +{ + string s; + while (std::cout << "Enter the book ISBN to look for: ", in >> s) { + auto trans = findBook(files, s); // stores that sold this book + if (trans.empty()) { + std::cout << s << " not found in any stores." << std::endl; + continue; // get the next book to look for + } + for (auto&& store : trans) { // // for every store with a sale + // get returns the specified member from the tuple in store + os << "store " << get<0>(store) + 1 << " sales: " + << std::accumulate(get<1>(store), get<2>(store), Sales_data()) + << std::endl; + } + std::cout << "----" << std::endl; + } +} +} \ No newline at end of file diff --git a/ch17/ex17_05_findBook.h b/ch17/ex17_05_findBook.h new file mode 100644 index 00000000..3318b14b --- /dev/null +++ b/ch17/ex17_05_findBook.h @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include + +#include "../ch14/ex14_45_sales_data.h" + +using std::pair; +using std::vector; +using std::string; +using std::make_pair; + +namespace EX05 { +using matches = pair::size_type, + pair::const_iterator, + vector::const_iterator>>; + +vector findBook(const vector>& files, + const string& book) +{ + vector ret; // initally empty + // for each store find the range of matching books, if any + for (auto it = files.cbegin(); it != files.cend(); ++it) { + // find the range of Sales_data that have the same ISBN + auto found = + std::equal_range(it->cbegin(), it->cend(), Sales_data(book), + [](const Sales_data& sd1, const Sales_data& sd2) { + return sd1.isbn() < sd2.isbn(); + }); + if (found.first != found.second) // this store had sales + // remember the index of this store and the matching range + ret.push_back(make_pair(it - files.cbegin(), + make_pair(found.first, found.second))); + } + return ret; // empty if no matches found +} + +void reportResults(std::istream& in, std::ostream& os, + const vector>& files) +{ + string s; + while (std::cout << "Enter the book ISBN to look for: ", in >> s) { + auto trans = findBook(files, s); // stores that sold this book + if (trans.empty()) { + std::cout << s << " not found in any stores." << std::endl; + continue; // get the next book to look for + } + for (auto&& store : trans) { // // for every store with a sale + // get returns the specified member from the tuple in store + os << "store " << store.first + 1 << " sales: " + << std::accumulate(store.second.first, store.second.second, + Sales_data(s)) + << std::endl; + } + std::cout << "----" << std::endl; + } +} +} \ No newline at end of file diff --git a/ch17/ex17_06_findBook.h b/ch17/ex17_06_findBook.h new file mode 100644 index 00000000..490f8183 --- /dev/null +++ b/ch17/ex17_06_findBook.h @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include + +#include "../ch14/ex14_45_sales_data.h" + +using std::pair; +using std::vector; +using std::string; +using std::make_pair; + +namespace EX06 { +struct Matches { + friend class Sales_data; + + Matches(vector::size_type i, + vector::const_iterator b, + vector::const_iterator e) + : index(i), begin(b), end(e) + { + } + + vector::size_type index; + vector::const_iterator begin; + vector::const_iterator end; +}; + +vector findBook(const vector>& files, + const string& book) +{ + vector ret; // initally empty + // for each store find the range of matching books, if any + for (auto it = files.cbegin(); it != files.cend(); ++it) { + // find the range of Sales_data that have the same ISBN + auto found = + std::equal_range(it->cbegin(), it->cend(), Sales_data(book), + [](const Sales_data& sd1, const Sales_data& sd2) { + return sd1.isbn() < sd2.isbn(); + }); + if (found.first != found.second) // this store had sales + // remember the index of this store and the matching range + ret.push_back( + Matches(it - files.cbegin(), found.first, found.second)); + } + return ret; // empty if no matches found +} + +void reportResults(std::istream& in, std::ostream& os, + const vector>& files) +{ + string s; + while (std::cout << "Enter the book ISBN to look for: ", in >> s) { + auto trans = findBook(files, s); // stores that sold this book + if (trans.empty()) { + std::cout << s << " not found in any stores." << std::endl; + continue; // get the next book to look for + } + for (auto&& store : trans) { // // for every store with a sale + // get returns the specified member from the tuple in store + os << "store " << store.index + 1 << " sales: " + << std::accumulate(store.begin, store.end, Sales_data(s)) + << std::endl; + } + std::cout << "----" << std::endl; + } +} +} \ No newline at end of file diff --git a/ch17/ex17_findBook_test.cpp b/ch17/ex17_findBook_test.cpp new file mode 100644 index 00000000..b42a3324 --- /dev/null +++ b/ch17/ex17_findBook_test.cpp @@ -0,0 +1,54 @@ +#include +#include + +#include "ex17_04_findBook.h" +#include "ex17_05_findBook.h" +#include "ex17_06_findBook.h" + +vector build_store(const string& s) +{ + vector ret; + std::ifstream is(s); + Sales_data item; + while (is >> item) ret.push_back(item); + sort(ret.begin(), ret.end(), + [](const Sales_data& lhs, const Sales_data& rhs) { + return lhs.isbn() < rhs.isbn(); + }); //! need sort for equal_range to work + return ret; +} + +int main() +{ + // each element in files holds the transactions for a particular store + vector> files; + for (int cnt = 1; cnt <= 4; ++cnt) + files.push_back(build_store("../data/store" + std::to_string(cnt))); + + EX04::reportResults(std::cin, std::cout, files); + // EX05::reportResults(std::cin, std::cout, files); + // EX06::reportResults(std::cin, std::cout, files); +} + +//! Compile +// cc ex17_findBook_test.cpp ../ch14/ex14_45_sales_data.cpp -std=c++11 -pedantic +// -Wall +// +//! Run +// Enter the book ISBN to look for: 0-201-70353-X +// store 1 sales: 0-201-70353-X 4 99.96 24.99 +// store 3 sales: 0-201-70353-X 4 99.96 24.99 +// store 4 sales: 0-201-70353-X 4 99.96 24.99 +// ---- +// Enter the book ISBN to look for: 0-201-88954-4 +// store 1 sales: 0-201-88954-4 16 198 12.375 +// store 3 sales: 0-201-88954-4 16 198 12.375 +// store 4 sales: 0-201-88954-4 16 198 12.375 +// ---- +// Enter the book ISBN to look for: 0-201-78345-X +// store 1 sales: 0-201-78345-X 5 110 22 +// store 2 sales: 0-201-78345-X 14 320 22.8571 +// store 3 sales: 0-201-78345-X 5 110 22 +// store 4 sales: 0-201-78345-X 5 110 22 +// ---- +// Enter the book ISBN to look for: \ No newline at end of file diff --git a/data/store1 b/data/store1 new file mode 100644 index 00000000..0d14afe8 --- /dev/null +++ b/data/store1 @@ -0,0 +1,10 @@ +0-201-70353-X 4 24.99 +0-201-82470-1 4 45.39 +0-201-88954-4 2 15.00 +0-201-88954-4 5 12.00 +0-201-88954-4 7 12.00 +0-201-88954-4 2 12.00 +0-399-82477-1 2 45.39 +0-399-82477-1 3 45.39 +0-201-78345-X 3 20.00 +0-201-78345-X 2 25.00 diff --git a/data/store2 b/data/store2 new file mode 100644 index 00000000..4224fa4d --- /dev/null +++ b/data/store2 @@ -0,0 +1,8 @@ +0-201-78345-X 3 20.00 +0-201-78345-X 2 25.00 +0-999-78345-X 3 20.00 +0-201-78345-X 2 25.00 +0-201-78345-X 3 20.00 +0-201-78345-X 2 25.00 +0-999-78345-X 3 20.00 +0-201-78345-X 2 25.00 diff --git a/data/store3 b/data/store3 new file mode 100644 index 00000000..0d14afe8 --- /dev/null +++ b/data/store3 @@ -0,0 +1,10 @@ +0-201-70353-X 4 24.99 +0-201-82470-1 4 45.39 +0-201-88954-4 2 15.00 +0-201-88954-4 5 12.00 +0-201-88954-4 7 12.00 +0-201-88954-4 2 12.00 +0-399-82477-1 2 45.39 +0-399-82477-1 3 45.39 +0-201-78345-X 3 20.00 +0-201-78345-X 2 25.00 diff --git a/data/store4 b/data/store4 new file mode 100644 index 00000000..0d14afe8 --- /dev/null +++ b/data/store4 @@ -0,0 +1,10 @@ +0-201-70353-X 4 24.99 +0-201-82470-1 4 45.39 +0-201-88954-4 2 15.00 +0-201-88954-4 5 12.00 +0-201-88954-4 7 12.00 +0-201-88954-4 2 12.00 +0-399-82477-1 2 45.39 +0-399-82477-1 3 45.39 +0-201-78345-X 3 20.00 +0-201-78345-X 2 25.00