fork(3) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. // class Book
  7. // with three private data fields: book title, author, copyright, and price
  8. // four public methods to retrieve fields (called "getters")
  9. // and one public non-default constructor
  10.  
  11. class Book {
  12.  
  13. public:
  14.  
  15. // member function prototypes
  16.  
  17. void releaseDate (int, int, int);
  18. void authorsName (string, string, string);
  19. void bookMainInfo (string, string, string, float, string, string);
  20. void bookDetailInfo (string, string, string, string, string);
  21.  
  22. int getMonth();
  23. int getDay();
  24. int getYear();
  25.  
  26. string getLast();
  27. string getFirst();
  28. string getMiddle();
  29.  
  30. string getTitleName();
  31. string getPublisherName();
  32. string getFormat();
  33. float getPrice();
  34. string getStarRating();
  35. string getSummary();
  36.  
  37. string getLanguage();
  38. string getISBN10();
  39. string getISBN13();
  40. string getShippingWeight();
  41. string getWeightClass();
  42.  
  43. private:
  44.  
  45. // data members
  46.  
  47.  
  48. int month;
  49. int day;
  50. int year;
  51.  
  52. string last;
  53. string first;
  54. string middle;
  55.  
  56. string titleName;
  57. string publisherName;
  58. string format;
  59. float price;
  60. string starRating;
  61. string summary;
  62.  
  63. string language;
  64. string ISBN10;
  65. string ISBN13;
  66. string shippingWeight;
  67. string weightClass;
  68. };
  69.  
  70.  
  71. // these are the actual member functions
  72.  
  73. // this member function is a "constructor" that will create a new book
  74. void Book::releaseDate (int releasehMonth, int releaseDay, int releaseYear) {
  75. month = releasehMonth;
  76. day = releaseDay;
  77. year = releaseYear;
  78. }
  79.  
  80. // this member function is a "getter" that will retrieve that book title value
  81. int Book::getMonth() {
  82. return month;
  83. }
  84. int Book::getDay() {
  85. return day;
  86. }
  87. int Book::getYear() {
  88. return year;
  89. }
  90.  
  91. void Book::authorsName(string authorsLastName, string authorsFirstName, string authorsMiddleName) {
  92. last = authorsLastName;
  93. first = authorsFirstName;
  94. middle = authorsMiddleName;
  95. }
  96. string Book::getLast() {
  97. return last;
  98. }
  99. string Book::getFirst() {
  100. return first;
  101. }
  102. string Book::getMiddle() {
  103. return middle;
  104. }
  105.  
  106. void Book::bookMainInfo(string bookTitleName, string bookPublisherName, string bookFormat, float bookPrice, string bookStarRating, string bookSummary){
  107. titleName = bookTitleName;
  108. publisherName = bookPublisherName;
  109. format = bookFormat;
  110. price = bookPrice;
  111. starRating = bookStarRating;
  112. summary = bookSummary;
  113. }
  114. string Book::getTitleName() {
  115. return titleName;
  116. }
  117. string Book::getPublisherName() {
  118. return publisherName;
  119. }
  120. string Book::getFormat() {
  121. return format;
  122. }
  123. float Book::getPrice() {
  124. return price;
  125. }
  126. string Book::getStarRating() {
  127. return starRating;
  128. }
  129. string Book::getSummary() {
  130. return summary;
  131. }
  132.  
  133. void Book::bookDetailInfo(string bookLanguage, string bookISBN10, string bookISBN13, string bookShippingWeight, string bookWeightClass){
  134. language = bookLanguage;
  135. ISBN10 = bookISBN10;
  136. ISBN13 = bookISBN13;
  137. shippingWeight = bookShippingWeight;
  138. weightClass = bookWeightClass;
  139. }
  140. string Book::getLanguage() {
  141. return language;
  142. }
  143. string Book::getISBN10() {
  144. return ISBN10;
  145. }
  146. string Book::getISBN13() {
  147. return ISBN13;
  148. }
  149. string Book::getShippingWeight() {
  150. return shippingWeight;
  151. }
  152. string Book::getWeightClass() {
  153. return weightClass;
  154. }
  155.  
  156. int main()
  157. {
  158.  
  159. // Set up space to create 5 instances of the class Book to use with our constructor
  160. Book B1;
  161.  
  162. // Use our constructor to create the first book, replace my book below with info on your favorite book, use b1
  163.  
  164. B1.authorsName ("King", "Stephen", "");
  165. cout << "Authors Name (Last, First, Middle): " << "\n" << B1.getLast() << ", " << B1.getFirst() << " " << B1.getMiddle() << endl;
  166. cout << "\n" << endl;
  167.  
  168. B1.releaseDate (04, 23, 1996);
  169. cout << "Release Date - " << B1.getMonth() << "/" << B1.getDay() << "/" << B1.getYear() << endl;
  170.  
  171. B1.bookMainInfo ("The Shining", "Mass Market Paperback", "Kindle", 12.01, "5", "This is the summary. This is the summary. This is the summary. \nThis is the summary. This is the summary. This is the summary. \nThis is the summary. This is the summary. This is the summary. ");
  172. cout << "Title: " << B1.getTitleName() << "\n" << "Publisher: " << B1.getPublisherName() << "\n" << "Format: " << B1.getFormat() << "\n" << "Price: " << "$" << B1.getPrice() << "\n" << "Stars: " << B1.getStarRating() << "\n" << "Summary: "<< B1.getSummary() << endl;
  173. cout << "\n" << endl;
  174.  
  175. B1.bookDetailInfo("English", "1234567891", "13-1234567891", "1.5", ".lbs");
  176. cout << "Language: " << B1.getLanguage() << "\n" << "ISBN10: " << B1.getISBN10() << "\n" << "ISBN13: " << B1.getISBN13() << "\n" << "Shipping Weight: " << B1.getShippingWeight() << "\n" << "Weight Class: " << B1.getWeightClass() << endl;
  177.  
  178. cout << "\n" << endl;
  179.  
  180. cout << "======================" << "\n" << endl;
  181. //================================================================================================
  182.  
  183. return (0);
  184. }
Success #stdin #stdout 0s 3420KB
stdin
Standard input is empty
stdout
Authors Name (Last, First, Middle): 
King, Stephen 


Release Date - 4/23/1996
Title: The Shining
Publisher: Mass Market Paperback
Format: Kindle
Price: $12.01
Stars: 5
Summary: This is the summary. This is the summary. This is the summary. 
This is the summary. This is the summary. This is the summary. 
This is the summary. This is the summary. This is the summary. 


Language: English
ISBN10: 1234567891
ISBN13: 13-1234567891
Shipping Weight: 1.5
Weight Class: .lbs


======================