Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You don't have to fix my code if you don't want to. Solving this assignment originally would be even more helpful, I'll adjust my own

You don't have to fix my code if you don't want to. Solving this assignment originally would be even more helpful, I'll adjust my own work to reflect your solution.

(Nobody answered the first time this was posted)

Due at the beginning of class. Hand in hard copy of your code and be prepared to run your program. Develop your program as follows: The main program and each class definition must be in separate files. Ensure your code conforms to your Style Guide. Part 1 Copies of Books The library has multiple copies of each book. Track the number of copies of each book, and track one borrower for each copy. Do not allow book check out if all copies are already checked out. Part 2 Publication Class In your Library Lab, rename Book to Publication wherever it appears. Test your program to ensure it works properly. Part 3 Book, Music, and Video classes Add a new Book class, as well as Music and Video classes. All three classes are derived from the Publication class. Add these member variables: Book class: pages format (hardcover, softcover, digital) Music class: duration (seconds) format (MP3, AAV, WAV) Video class: resolution (low, high, 4K) producer Add constructors, get functions, and set functions as needed. Part 4 Overdue Publications Write a Date class with member variables year, month, and day, and member functions as needed. Add an overloaded - operator, which calculates days between two Date objects. Publications may be checked out for 21 days. In your main program, add a menu option to enter todays date. When a Publication is checked out, save todays date. When a Publication is checked in, indicate if it is overdue and tell subscriber to pay a fine of 5 cents per day.

Totally lost, this is what I have so far:

#ifndef libtest_h #define libtest_h #include #include using namespace std; class Person{ public: string name, email; static int count; int number; Person(const string n, const string e, const short int num){ name=n; email=e; number=num; } Person(){ name=" "; email=" "; number=0; } void personarrayconstructor(const string n, const string e, const short int num){ name=n; email=e; number=num; } }; class Publication{ public: int copies, number; static int count2; string title, author; void checkin(Person&, int&, int&); void checkout(Person&, int&, int&); Publication (const string t, const string a, const short int num, const short int c){ title=t; author=a; number=num; copies=c; } Publication(){ title=" "; author=" "; copies=0; number=0; } void whywontconstructorsworkwitharrays(const string t, const string a, const short int num, const short int c){ title=t; author=a; number=num; copies=c; } }; class Date { public: void debt(Date &, Date &); int month, day, year; Date(){ month=0; day=0; year=0; } Date(int m, int d, int y){ month=m; day=d; year=y; } int operator- (Date D) { year*=365; D.year*=365; month*=30; D.month*=30; int diff, add1, add2; add1=year+month+day; add2=D.year+D.month+D.day; if (add1> d1.month; while (d1.month<1||d1.month>12) { cout << "Enter a real month. "; cin >> d1.month; } cout << "Day #: "; cin >> d1.day; while (d1.day<1||d1.day>30) { cout << "Enter a real day. "; cin >> d1.day; } cout << "Year: "; cin >> d1.year; while (d1.year<2010||d1.year>2025) { cout << "Enter a real year. "; cin >> d1.year; } cout << "You have 21 days to return this album. Overdue fees are $0.25 per day. "; } void Date:: displaydatein(Date &d1, Date &d2){ cout << "Please enter date of checkin. "; cout << "Month #: "; cin >> d2.month; while (d2.month<1||d2.month>12) { cout << "Enter a real month. "; cin >> d2.month; } cout << "Day #: "; cin >> d2.day; while (d2.day<1||d2.day>30) { cout << "Enter a real day. "; cin >> d2.day; } cout << "Year: "; cin >> d2.year; while (d2.year<2010||d2.year>2025) { cout << "Enter a real year. "; cin >> d2.year; } d1.debt(d1,d2); } void Date::setzero(Date &d1, Date &d2){ d1.month=0; d2.month=0; d1.day=0; d2.day=0; d1.year=0; d2.year=0; } void Date::debt(Date &d1, Date &d2){ double debt; debt=d1-d2; if (debt>=21) { debt*=.25; if (debt >= 1) { cout << "You owe $" << debt << " in overdue fees for this book. "; } if (debt < 1) { cout << "You owe " << debt << " cents in overdue fees for this book. "; } } else{ cout << "Book turned in on time. You had " << debt << " more days to turn it in before we charge 5 cents extra per day. "; } } #endif

#include #include #include /*#include "people.h" #include "publication.h" #include "date.h" #include "books.h" #include "music.h" #include "vids.h"*/ #include "libtest.h" using namespace std; void deletebooks(Book books, int num); void deletevids(Video vid, int num); void deletemus(Music mus, int num); int main(){ //fixed; setprecision(2); const short int SIZEPPL=7, SIZEBOOKS=4, SIZEMUS=4, SIZEVID=4, SIZEBORROW=9; int num, num2=1000, num3=1000, inum=510, type[3]={1,2,3}; Date d1, d2; char choice; Publication p; Person ppl[SIZEPPL]; Person nulguy; ppl[0].personarrayconstructor("Example Example@exmpl.co", 1); ppl[1].personarrayconstructor("Other Guy", "otherguy@aol.com", 2); ppl[2].personarrayconstructor("Reading Boi", "readingboi@schoolastic.org", 3); ppl[3].personarrayconstructor("UFO", "UFO@area51.com", 4); ppl[4].personarrayconstructor("Cant", "Cant@even.gov", 5); ppl[5].personarrayconstructor("Think", "think@branium.eu", 6); ppl[6].personarrayconstructor("RN", "RN@rnnow.com", 7);

Book books[SIZEBOOKS]; books[0].bookarrayconstructor(69, "Softcover","Captain Underpants", "Dav Pilkey", 1, 9); books[1].bookarrayconstructor(143, "Softcover","Goosebumps", "R. L. Stine", 2, 5); books[2].bookarrayconstructor(304, "Hardcopy", "Animorphs", "K. A. Applegate", 3, 1); books[3].bookarrayconstructor(510, "Hardcopy", "Spiderman", "Stan Lee", 4, 4);

Music mus[SIZEMUS]; mus[0].musicarrayconstructor(6.43, "MP4", " ", " ", 1, 4); mus[1].musicarrayconstructor(0.21, "MP3", " ", " ", 2, 3); mus[2].musicarrayconstructor(3.10, "MP3", " ", " ", 3, 2); mus[3].musicarrayconstructor(597325.12, "MP3", " ", " ", 4, 8);

Video vid[SIZEVID]; vid[0].vidarrayconstructor(7680, "The Wayans Brothers", "Don't Be a Menace to South Central While Drinking Your Juice in the Hood", " ", 1, 7); vid[1].vidarrayconstructor(144, "George Lucas", "Starwars", " ", 2, 4); vid[2].vidarrayconstructor(2048, "Dave Chappelle", "The Chappelle Show", " ", 3, 5); vid[3].vidarrayconstructor(1080, "Stan Lee", "Venom", " ", 4, 6);

do{ d1.setzero(d1,d2); cout<< "What do you want to do? "; cout << "1) See people's names and what they have checked out "; cout << "2) See the items and who has them checked out "; cout << "3) Check out an item(s) "; cout << "4) Check in an item(s) "; cout << "0) To exit "; cin >> num; if (num==1) { for (int i=0; i

if (num==2) { do { cout << "Which item would you like to view? "; cout << "1) Books "; cout << "2) Videos "; cout << "3) Music "; cout << "0) Exit "; cin >> inum; if (inum==1) { for (int i=0; i

if (inum==2) { for (int i=0; i

if (num==3) { cout << "What do you want to check out? Enter 'B' for book, 'V' for video, or 'M' for music. "; cin >> choice; switch (choice) { case 'b': case 'B': cout << "Which book would you like to check out? Enter the ID number of it. "; cin >> num2; num2-=1; if (Book::bookborrow[num2][Publication::count2]>books[num2].pub.copies) { cout << "All copies of this book are checked out. "; } else{ cout << "Who's checking out this book? Enter their ID number. "; cin >> num3; num3-=1; books[num2].pub.checkout(ppl[num3],num2,type[0]); d1.displaydueout(d1, d2); } break; case 'v': case 'V': cout << "Which video would you like to check out? Enter the ID number of it. "; cin >> num2; num2-=1; if (Video::vidborrow[num2][Publication::count2]>vid[num2].pub.copies) { cout << "All copies of this video are checked out. "; } else{ cout << "Who's checking out this video? Enter their ID number. "; cin >> num3; num3-=1; vid[num2].pub.checkout(ppl[num3],num2,type[1]); d1.displaydueout(d1, d2); } break; case 'm': case 'M': cout << "Which song would you like to check out? Enter the ID number of it. "; cin >> num2; num2-=1; if (Music::musborrow[num2][Publication::count2]>mus[num2].pub.copies) { cout << "All copies of this album are checked out. "; } else{ cout << "Who's checking out this album? Enter their ID number. "; cin >> num3; num3-=1; mus[num2].pub.checkout(ppl[num3],num2,type[2]); d1.displaydueout(d1, d2); } break; default: cout << "You entered an invalid character. "; break; } }

if (num==4) { cout << "What do you want to check in? Enter 'B' for book, 'V' for video, or 'M' for music. "; cin >> choice; switch (choice) { case 'b': case 'B': cout << "Which book would you like to check in? Enter the ID number of it. "; cin >> num2; num2-=1; if (Book::bookborrow[num2][Publication::count2]<=0) { cout << "All copies of this book are already checked in! "; } else{ cout << "Who's checking in this book? Enter their ID number. "; cin >> num3; books[num2].pub.checkin(ppl[num3],num2,type[0]); d1.displaydatein(d1, d2); } break; case 'v': case 'V': cout << "Which video would you like to check in? Enter the ID number of it. "; cin >> num2; num2-=1; if (Video::vidborrow[num2][Publication::count2]<=0) { cout << "All copies of this video are already checked in! "; } else{ cout << "Who's checking in this video? Enter their ID number. "; cin >> num3; vid[num2].pub.checkin(ppl[num3],num2,type[1]); d1.displaydatein(d1, d2); } break; case 'm': case 'M': cout << "Which song would you like to check in? Enter the ID number of it. "; cin >> num2; num2-=1; if (Music::musborrow[num2][Publication::count2]<=0) { cout << "All copies of this album are already checked in! "; } else{ cout << "Who's checking in this album? Enter their ID number. "; cin >> num3; mus[num2].pub.checkin(ppl[num3],num2,type[2]); d1.displaydatein(d1, d2); } break; default: cout << "You entered an invalid character. "; break; } } }while(num!=0); return 0; }

/*void deletebooks(Book books, int num){ bool bye[books.pub.copies]; for (int i=0; i

*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

Students also viewed these Databases questions

Question

Draw and name the 17 hexene isomers, C6H2, including E, Z isomers.

Answered: 1 week ago