Homework 4 Homework 4 This Homework is a follow-on to Homework 3 (a previous order code that I will provide) in which we will add an inheritance component to the Movie portion of the application. This...

1 answer below »
The Homework 4 file that I attached explains the assignment, and the zip file is the code associated with the homework, this assignment is an add on to my previous order (85056, like before all code should be in c++.


Homework 4 Homework 4 This Homework is a follow-on to Homework 3 (a previous order code that I will provide) in which we will add an inheritance component to the Movie portion of the application. This will require modifications to both the design and code components of the previous assignment. The details are provided below. You should create a new class called Entitem (short for Entertainment Item) that will be the base class for the inheritance tree. It should contain at least the following data elements: ● ID # ● Cost ● Status (In, out, lost) ● Loan period(how long it can be checked out for-note this could be 0) (24 hours for movies, 48 hours for games) It will also need appropriate accessor and mutator functions. You may also add additional data elements if needed. Then there will be two child classes of Entitem (Movie and Game) movie (lower-case) should contain the other items that we previously in the Book class not included above, at least: ● Title (up to 40 characters) ● Release date (mm/yyyy) ● Rating (up to 20 characters) ● Duration (hh:mm) ● Rental Cost ($dd.cc) ● Replacement Cost ($dd.cc) *movie will have its own .cpp and .h files Game should contain at least: ● Rating (20 char max) ● Genre (Battle, sci-Fi, racing, sports, etc) (40 char max) ● Title (40 char max) ● Release date (mm/yyyy ● Studio/Company Name (40 char max) ● Rental Cost ($dd.cc) ● Replacement Cost ($dd.cc) *Game will have its own .cpp and .h files Implement the child classes, including virtual functions. Update the collection class to be a heterogeneous collection using virtual functions and run-time polymorphism. Create at least one overloaded operator to use within the polymorphic collection. A good suggestion would be an overloaded < operator="" (insertion="" operator)="" that="" can="" be="" used="" with="" cout="" as="" well="" as="" file="" ostreams.="" __macosx/._jcchwk3="" jcchwk3/customers.cpp="" #include=""> #include "Movie.cpp" #include #include "Customer.h" #include "Customer.cpp" #include "Loan.cpp" #include #include #include #include "Customers.h" using namespace std; vector customerlist; void loadCustomer() { // File pointer ifstream fin("customer.csv"); // Open an existing file while (!fin.is_open()) { return; } // Read the Data from the file // as String Vector string line, word; string x, y, a, b, c, d; // read every column data of a row and // store it in a string variable, 'word' while (getline(fin, line)) { stringstream ss(line); getline(ss, x, ','); getline(ss, y, ','); getline(ss, a, ','); getline(ss, b, ','); getline(ss, c, ','); getline(ss, d, ','); Customer cust(stoi(x), stol(y), a, b, stoi(c), stoi(d)); // add all the column data // of a row to a vector customerlist.push_back(cust); } } void addCustomer() { int id; long cardNo; string name = "", expirydate = ""; int cardkey, activemovies; cout < "enter="" customer="" data(id,cardno,name,expirydate,cardkey,activemovies)";="" cout="">< "id:";="" cin="">> id; cout < endl;="" cout="">< "active="" movies:";="" cin="">> activemovies; cout < endl;="" cout="">< "cardno:";="" cin="">> cardNo; cout < endl;="" cout="">< "name:";="" cin="">> name; cout < endl;="" cout="">< "expiry="" date:";="" cin="">> expirydate; cout < endl;="" cout="">< "cardkey:";="" cin="">> cardkey; cout < endl;="" cin="">> id >> cardNo >> name >> expirydate >> cardkey >> activemovies; Customer customer(id, cardNo, name, expirydate, cardkey, activemovies); customerlist.push_back(customer); } Customer *searchCustomer() { string name = ""; cout < "enter="" customer="" name";="" cin="">> name; bool flag = false; for (auto &it : customerlist) { if (it.getName().compare(name) == 0) { flag = true; cout < "data="" found";="" cout="">< "id:"="">< it.getid()="">< "name"="">< it.getname()="">< "card="" no"="">< it.getcardno()="">< "="" expiry="" date"="">< it.getexpirydate()="">< "="" card="" key="" "="">< it.getcardkey()="">< "="" active="" movies="" "="">< it.getactivemovies()="">< endl;="" return="" ⁢="" }="" }="" if="" (!flag)="" {="" cout="">< "data="" not="" found";="" }="" return="" nullptr;="" }="" void="" displaycustomer()="" {="" for="" (auto="" &it="" :="" customerlist)="" {="" cout="">< "id:"="">< it.getid()="">< "name"="">< it.getname()="">< "card="" no"="">< it.getcardno()="">< "="" expiry="" date"="">< it.getexpirydate()="">< "="" card="" key="" "="">< it.getcardkey()="">< "="" active="" movies="" "="">< it.getactivemovies()="">< endl;="" }="" }="" void="" displayfirstcustomer()="" {="" cout="">< "id:"="">< customerlist[0].getid()="">< "name"="">< customerlist[0].getname()="">< "card="" no"="">< customerlist[0].getcardno()="">< "="" expiry="" date"="">< customerlist[0].getexpirydate()="">< "="" card="" key="" "="">< customerlist[0].getcardkey()="">< "="" active="" movies="" "="">< customerlist[0].getactivemovies()="">< endl;="" }="" void="" editcustomer()="" {="" customer="" *customer="searchCustomer();" if="" (customer="=" nullptr)="" return;="" int="" id;="" long="" cardno;="" string="" name="" ,="" expirydate="" ;="" int="" cardkey,="" activemovies;="" cout="">< "enter="" customer="" data(id,cardno,name,expirydate,cardkey,activemovies)";="" cout="">< "id:";="" cin="">> id; cout < endl;="" cout="">< "active="" movies:";="" cin="">> activemovies; cout < endl;="" cout="">< "cardno:";="" cin="">> cardNo; cout < endl;="" cout="">< "name:";="" cin="">> name; cout < endl;="" cout="">< "expiry="" date:";="" cin="">> expirydate; cout < endl;="" cout="">< "cardkey:";="" cin="">> cardkey; cout < endl;="" cin="">> id >> cardNo >> name >> expirydate >> cardkey >> activemovies; customer->setId(id); customer->setName(name); customer->setCardNo(cardNo); customer->setExpiryDate(expirydate); customer->setCardKey(cardkey); customer->setActiveMovies(activemovies); } __MACOSX/jcchwk3/._Customers.cpp jcchwk3/class diagram.docx __MACOSX/jcchwk3/._class diagram.docx jcchwk3/Loan.cpp #include "Loan.h" Loan:: Loan(int id, int movieId, int customerId, string duedate, string duetime, string duration, string status) { this->id = id; this->movieId = movieId; this->customerId = customerId; this->duedate = duedate; this->duetime = duetime; this->duration = duration; this->status = status; } int Loan::getId() { return this->id; } int Loan::getMovieId() { return this->movieId; } int Loan::getCustomerId() { return this->customerId; } string Loan::getDueDate() { return this->duedate; } string Loan::getDueTime() { return this->duetime; } string Loan::getDuration() { return this->duration; } string Loan::getStatus() { return this->status; } void Loan::setId(int id) { this->id=id; } void Loan::setMovieId(int movieId) { this->movieId=movieId; } void Loan::setCustomerId(int customerId) { this->customerId=customerId; } void Loan::setDueDate(string duedate) { this->duedate=duedate; } void Loan::setDueTime(string duetime) { this->duetime=duetime; } void Loan::setDuration(string duration) { this->duration=duration; } void Loan::setStatus(string status) { this->status=status; } __MACOSX/jcchwk3/._Loan.cpp jcchwk3/.DS_Store __MACOSX/jcchwk3/._.DS_Store jcchwk3/Loan.h #include #include using namespace std; #ifndef LOAN_H #define LOAN_H class Loan { private: int id; int movieId; int customerId; string duedate; string duetime; string duration; string status; public: Loan(int id, int movieId, int customerId, string duedate, string duetime, string duration, string status); int getId(); int getMovieId(); int getCustomerId(); string getDueDate(); string getDueTime(); string getDuration(); string getStatus(); void setId(int id); void setMovieId(int movieId); void setCustomerId(int customerId); void setDueDate(string duedate); void setDueTime(string duetime); void setDuration(string duration); void setStatus(string status); }; #endif // LOAN_H __MACOSX/jcchwk3/._Loan.h jcchwk3/Movie.h #include #include using namespace std; #ifndef MOVIE_H #define MOVIE_H class Movie { private: int id; string title; string releasedate; string rating; string duration; string rentalcost; string replacementcost; public: Movie(int id, string title, string releasedate, string rating,string
Answered 4 days AfterJun 16, 2021

Answer To: Homework 4 Homework 4 This Homework is a follow-on to Homework 3 (a previous order code that I will...

Rushendra answered on Jun 21 2021
137 Votes
jcchwk3/.DS_Store
jcchwk3/a.exe
jcchwk3/class diagram.docx
jcchwk3/Customer.cpp
jcchwk3/Customer.cpp
#include "Customer.h"
#include
#include
using namespace std;
Customer::Customer(int id,  long cardNo,string name,string expirydate, int cardkey,int activeMovies)
{
    this->id=id;
    this->cardNo=cardNo;
    this->name=name;
    this->expirydate=expirydate;
    this->cardkey=cardkey;
    this->activeMovies=activeMovies;
}
int Customer::getId()
{
    return this->id;
}
long Customer::getCardNo()
{
    return this->cardNo;
}
string Customer::getName()
{
    return this->name;
}
string  Customer::getExpiryDate()
{
    return this->expirydate;
}
int Customer::getCardKey()
{
    return this->cardkey;
}
int Customer::getActiveMovies()
{
    return this->activeMovies;
}
void Customer::setId(int id)
{
    this->id=id;
}
void Customer::setCardNo(long card
no)
{
    this->cardNo=cardno;
}
void Customer::setName(string name)
{
    this->name=name;
}
void Customer::setExpiryDate(string expiryname)
{
    this->expirydate=expirydate;
}
void Customer::setCardKey(int cardkey)
{
    this->cardkey=cardkey;
}
void Customer::setActiveMovies(int activeMovies)
{
    this->activeMovies=activeMovies;
}
jcchwk3/Customer.h
#include
#include
using namespace std;
#ifndef CUSTOMER_H
#define CUSTOMER_H
class Customer
{
private:
int id;
long cardNo;
string name;
string expirydate;
int activeMovies;
int cardkey;
public:
Customer(int id, long cardNo,string name,string expirydate, int cardkey,int activeMovies);
int getId();
long getCardNo();
string getName();
string getExpiryDate();
int getCardKey();
int getActiveMovies();
void setId(int id);
void setCardNo(long cardno);
void setName(string name);
void setExpiryDate(string expiryname);
void setCardKey(int cardkey);
void setActiveMovies(int activeMovies);
};
#endif // CUSTOMER_H
jcchwk3/Customers.cpp
#include
#include "Movie.cpp"
#include
#include "Customer.h"
#include "Customer.cpp"
#include "Loan.cpp"
#include
#include
#include
#include "Customers.h"
using namespace std;
vector customerlist;
void loadCustomer()
{
// File pointer
ifstream fin("customer.csv");
// Open an existing file
while (!fin.is_open())
{
return;
}
// Read the Data from the file
// as String Vector
string line, word;
string x, y, a, b, c, d;
// read every column data of a row and
// store it in a string variable, 'word'
while (getline(fin, line))
{
stringstream ss(line);
getline(ss, x, ',');
getline(ss, y, ',');
getline(ss, a, ',');
getline(ss, b, ',');
getline(ss, c, ',');
getline(ss, d, ',');
Customer cust(stoi(x), stol(y), a, b, stoi(c), stoi(d));
// add all the column data
// of a row to a vector
customerlist.push_back(cust);
}
}
void addCustomer()
{
int id;
long cardNo;
string name = "", expirydate = "";
int cardkey, activemovies;
cout << "Enter Customer Data(id,cardNo,name,expirydate,cardkey,activemovies)";
cout << "Id:";
cin >> id;
cout << endl;
cout << "active movies:";
cin >> activemovies;
cout << endl;
cout << "CardNo:";
cin >> cardNo;
cout << endl;

cout << "name:";
cin >> name;
cout << endl;

cout << "expiry date:";
cin >> expirydate;
cout << endl;

cout << "cardkey:";
cin >> cardkey;
cout << endl;

//cin >> id >> cardNo >> name >> expirydate >> cardkey >> activemovies;
Customer customer(id, cardNo, name, expirydate, cardkey, activemovies);
customerlist.push_back(customer);
}
Customer *searchCustomer()
{
string name = "";
cout << "Enter Customer Name";
cin >> name;
bool flag = false;
for (auto &it : customerlist)
{
if (it.getName().compare(name) == 0)
{
flag = true;
cout << "Data Found";
cout << "Id:" << it.getId() << "Name" << it.getName() << "Card No" << it.getCardNo() << " Expiry Date" << it.getExpiryDate() << " Card Key " << it.getCardKey() << " Active Movies " << it.getActiveMovies() << endl;
return ⁢
}
}
if (!flag)
{
cout << "Data Not Found";
}
return nullptr;
}
void displayCustomer()
{
for (auto &it : customerlist)
{
cout << "Id:" << it.getId() << "Name" << it.getName() << "Card No" << it.getCardNo() << " Expiry Date" << it.getExpiryDate() << " Card Key " << it.getCardKey() << " Active Movies " << it.getActiveMovies() << endl;
}
}
void displayFirstCustomer()
{
cout << "Id:" << customerlist[0].getId() << "Name" << customerlist[0].getName() << "Card No" << customerlist[0].getCardNo() << " Expiry Date" << customerlist[0].getExpiryDate() << " Card Key " << customerlist[0].getCardKey() << " Active Movies " << customerlist[0].getActiveMovies() << endl;
}
void editCustomer()
{
Customer *customer = searchCustomer();
if (customer == nullptr)
return;
int id;
long cardNo;
string name = "", expirydate = "";
int cardkey, activemovies;
cout << "Enter Customer Data(id,cardNo,name,expirydate,cardkey,activemovies)";

cout << "Id:";
cin >> id;
cout << endl;
cout << "active movies:";
cin >> activemovies;
cout << endl;
cout << "CardNo:";
cin >> cardNo;
cout << endl;

cout << "name:";
cin >> name;
cout << endl;

cout << "expiry date:";
cin >> expirydate;
cout << endl;

cout << "cardkey:";
cin >> cardkey;
cout << endl;
//cin >> id >> cardNo >> name >> expirydate >> cardkey >> activemovies;
customer->setId(id);
customer->setName(name);
customer->setCardNo(cardNo);
customer->setExpiryDate(expirydate);
customer->setCardKey(cardkey);
customer->setActiveMovies(activemovies);
}
jcchwk3/Customers.h
#include
#include
#include "Customer.h"
using namespace std;
#ifndef CUSTOMERS_H
#define CUSTOMERS_H
void loadCustomer();
void addCustomer();
Customer *searchCustomer();
void displayCustomer();
void displayFirstCustomer();
void editCustomer();
#endif // MOVIE_H
jcchwk3/Entitem.cpp
#include "Entitem.h"
// Entitem:: Entitem(int id, long cost,string status,int loanPeriod)
// {
// this->id=id;
// this->cost=cost;
// this->status=status;
// this->loanPeriod=loanPeriod;
// }
int Entitem::getId()
{
return this->id;
}
long Entitem::getCost()
{
return this->cost;
}
string Entitem::getStatus()
{
return this->status;
}
int Entitem::getLoanPeriod()
{
return this->loanPeriod;
}
void Entitem::setId(int id)
{
this->id=id;
}
void Entitem::setCost(long cost)
{
this->cost=cost;
}
void Entitem::setStatus(string status)
{
this->status=status;
}
void Entitem::setLoanPeriod(int loanPeriod)
{
this->loanPeriod=loanPeriod;
}
jcchwk3/Entitem.h
#include
#include
using namespace std;
#ifndef ENTITEM_H
#define ENTITEM_H
class Entitem
{
private:
int id;
long cost;
string status;

int loanPeriod;

public:
// Entitem(int id, long cost,string status,int loanPeriod);
int getId();
long getCost();
string getStatus();
int getLoanPeriod();
void setId(int id);
void setCost(long cost);
void setStatus(string status);
void setLoanPeriod(int loanPeriod);
};
#endif // CUSTOMER_H
jcchwk3/Game.cpp
#include "Game.h"
Game::Game(string rating, string genre,string title,string release_date,string studio,string rental_cost,string replacement_cost)
{
this->rating=rating;
this->genre=genre;
this->title=title;
this->release_date=release_date;
this->studio=studio;
this->rental_cost=rental_cost;
this->release_date=release_date;
this->replacement_cost=replacement_cost;
}
string Game::getRating()
{
return this->rating;
}
string Game::getGenre()
{
return this->genre;
}
string Game::getTitle()
{
return this->title;
}
string Game::getReleaseDate()
{
return this->release_date;
}
string Game::getStudio()
{
return this->studio;
}
string Game::getRentalCost()
{
return this->rental_cost;
}
string Game::getReplacementCost()
{
return this->replacement_cost;
}
void Game::setRating(string rating)
{
this->rating=rating;
}
void Game::setGenre(string genre)
{
this->genre=genre;
}
void Game::setTitle(string title)
{
this->title=title;
}
void Game::setReleaseDate(string release_date)
{
this->release_date=release_date;
}
void Game::setStudio(string studio)
{
this->studio=studio;
}
void Game::setRentalCost(string rentalCost)
{
this->rental_cost=rentalCost;
}
void Game::setReplacementCost(string replacement_cost)
{
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here