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
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 cardno)
{
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)
{
...