SlideShare a Scribd company logo
1 of 18
Download to read offline
Reveiwing the following code please answer the following questions
1. Discuss the data structures used
2. Discuss the algorithm used to search the list for a particular video and the time complexity of
the algorithm
#include
#include
#include
class VideoType
{
private:
std::wstring movieTitle;
std::wstring producer;
std::wstring director;
std::wstring company;
int noOfCopies = 0;
//
public:
VideoType(const std::wstring &movieTitle, const std::wstring &producer, const std::wstring
&director, const std::wstring &company, int noOfCopies);
//
virtual std::wstring getMovieTitle();
virtual void setMovieTitle(const std::wstring &movieTitle);
virtual std::wstring getProducer();
virtual void setProducer(const std::wstring &producer);
virtual std::wstring getDirector();
virtual void setDirector(const std::wstring &director);
virtual std::wstring getCompany();
virtual void setCompany(const std::wstring &company);
virtual int getNoOfCopies();
virtual void setNoOfCopies(int noOfCopies);
//
/*
* Rent video to customer
*/
virtual bool rentVideo(CustomerType *customer);
/*
* If customer has video, return it back to stock
*/
virtual bool returnVideo(CustomerType *cusomer);
//
/*
* If video is available in stock
*/
virtual bool isAvailableInStore();
//
virtual std::wstring toString() override;
};
VideoType::VideoType(const std::wstring &movieTitle, const std::wstring &producer, const
std::wstring &director, const std::wstring &company, int noOfCopies)
{ this->movieTitle = movieTitle;
this->producer = producer;
this->director = director;
this->company = company;
this->noOfCopies = noOfCopies;
}
std::wstring VideoType::getMovieTitle()
{
return movieTitle;
}
void VideoType::setMovieTitle(const std::wstring &movieTitle)
{
this->movieTitle = movieTitle;
}
std::wstring VideoType::getProducer()
{
return producer;
}
void VideoType::setProducer(const std::wstring &producer)
{
this->producer = producer;
}
std::wstring VideoType::getDirector()
{
return director;
}
void VideoType::setDirector(const std::wstring &director)
{
this->director = director;
}
std::wstring VideoType::getCompany()
{
return company;
}
void VideoType::setCompany(const std::wstring &company)
{
this->company = company;
}
int VideoType::getNoOfCopies()
{
return noOfCopies;
}
void VideoType::setNoOfCopies(int noOfCopies)
{
this->noOfCopies = noOfCopies;
}
bool VideoType::rentVideo(CustomerType *customer)
{
if (noOfCopies > 0)
{
customer->addVideo(this);
noOfCopies--;
return true;
}
return false;
}
bool VideoType::returnVideo(CustomerType *cusomer)
{
if (cusomer->hasVideo(this))
{
cusomer->returnVideo(this);
noOfCopies++;
return true;
}
return false;
}
bool VideoType::isAvailableInStore()
{
return noOfCopies > 0? true: false;
}
std::wstring VideoType::toString()
{
return std::wstring(L"Title: ") + movieTitle + std::wstring(L" Producer: ") + producer +
std::wstring(L" Director: ") + director + std::wstring(L" Company: ") + company +
std::wstring(L" Stock: ") + std::to_wstring(noOfCopies);
}
#include
#include
#include "stringbuilder.h"
public:
CustomerType::java *import;
class CustomerType
{
private:
std::wstring firstName;
std::wstring lastName;
std::wstring accountNumber;
std::vector rentedVideos;
//
public:
CustomerType(const std::wstring &firstName, const std::wstring &lastName, const std::wstring
&accountNumber);
virtual std::wstring getFirstName();
virtual void setFirstName(const std::wstring &firstName);
virtual std::wstring getLastName();
virtual void setLastName(const std::wstring &lastName);
virtual std::wstring getAccountNumber();
virtual void setAccountNumber(const std::wstring &accountNumber);
//
virtual void addVideo(VideoType *v);
virtual std::wstring toString() override;
virtual void returnVideo(VideoType *video);
/*
* Check if customer has a video
*/
virtual bool hasVideo(VideoType *video);
};
#include
#include
class StringBuilder
{
private:
std::wstring privateString;
public:
StringBuilder()
{
}
StringBuilder(const std::wstring &initialString)
{
privateString = initialString;
}
StringBuilder(std::size_t capacity)
{
ensureCapacity(capacity);
}
wchar_t charAt(std::size_t index)
{
return privateString[index];
}
StringBuilder *append(const std::wstring &toAppend)
{
privateString += toAppend;
return this;
}
template
StringBuilder *append(const T &toAppend)
{
privateString += toString(toAppend);
return this;
}
StringBuilder *insert(std::size_t position, const std::wstring &toInsert)
{
privateString.insert(position, toInsert);
return this;
}
template
StringBuilder *insert(std::size_t position, const T &toInsert)
{
privateString.insert(position, toString(toInsert));
return this;
}
std::wstring toString()
{
return privateString;
}
std::size_t length()
{
return privateString.length();
}
void setLength(std::size_t newLength)
{
privateString.resize(newLength);
}
std::size_t capacity()
{
return privateString.capacity();
}
void ensureCapacity(std::size_t minimumCapacity)
{
privateString.reserve(minimumCapacity);
}
StringBuilder *remove(std::size_t start, std::size_t end)
{
privateString.erase(start, end - start);
return this;
}
StringBuilder *replace(std::size_t start, std::size_t end, const std::wstring &newString)
{
privateString.replace(start, end - start, newString);
return this;
}
private:
template
static std::wstring toString(const T &subject)
{
std::wostringstream ss;
ss << subject;
return ss.str();
}
};
CustomerType::CustomerType(const std::wstring &firstName, const std::wstring &lastName,
const std::wstring &accountNumber)
{
this->firstName = firstName;
this->lastName = lastName;
this->accountNumber = accountNumber;
}
std::wstring CustomerType::getFirstName()
{
return firstName;
}
void CustomerType::setFirstName(const std::wstring &firstName)
{
this->firstName = firstName;
}
std::wstring CustomerType::getLastName()
{
return lastName;
}
void CustomerType::setLastName(const std::wstring &lastName)
{
this->lastName = lastName;
}
std::wstring CustomerType::getAccountNumber()
{
return accountNumber;
}
void CustomerType::setAccountNumber(const std::wstring &accountNumber)
{
this->accountNumber = accountNumber;
}
void CustomerType::addVideo(VideoType *v)
{
rentedVideos.push_back(v);
}
std::wstring CustomerType::toString()
{
StringBuilder *s = new StringBuilder();
s->append(std::wstring(L"Name: ") + firstName + std::wstring(L" ") + lastName +
std::wstring(L" Account Number: ") + accountNumber + std::wstring(L" Rented Videos :
"));
std::vector::const_iterator i = rentedVideos.begin();
while (i != rentedVideos.end())
{
s->append(*i.getMovieTitle());
s->append(L" ");
i++;
}
//
return s->toString();
//
}
void CustomerType::returnVideo(VideoType *video)
{
rentedVideos.remove(video);
}
bool CustomerType::hasVideo(VideoType *video)
{
if (rentedVideos.find(video) != -1)
{
return true;
}
else
{
return false;
}
}
//.h file code:
#include
#include
#include
public:
VideoStore::java *import;
class VideoStore
{
public:
static std::vector listOfVideos;
static std::vector listOfCustomers;
static Scanner *s;
/*
* Read from file videos.txt and create video list
*/
static void createVideoList();
/*
* Read from file customers.txt and create Customer list
*/
static void createCustomerList();
/*
* Prompt user to select a customer
*/
static CustomerType *getCustomer();
/*
* Prompt user to select a video
*/
static VideoType *getVideo();
//
std::vector VideoStore::listOfVideos;
std::vector VideoStore::listOfCustomers;
java::util::Scanner *VideoStore::s = new java::util::Scanner(System::in);
void VideoStore::createVideoList()
{
try
{
BufferedReader *videoFile = nullptr;
FileReader tempVar(L"videos.txt");
videoFile = new BufferedReader(&tempVar);
videoFile->readLine(); // to flush comment line
for (std::wstring line = videoFile->readLine(); (line != L""); line = videoFile-
>readLine())
{
std::vector parts = line.split(L"t");
VideoType tempVar2(parts[0], parts[1], parts[2], parts[3], std::stoi(parts[4]));
listOfVideos.push_back(&tempVar2);
}
delete videoFile;
}
catch (const IOException &e)
{
System::err::print(e);
exit(-1);
}
}
void VideoStore::createCustomerList()
{
try
{
BufferedReader *customerFile = nullptr;
FileReader tempVar(L"customers.txt");
customerFile = new BufferedReader(&tempVar);
customerFile->readLine(); // to flush comment line
for (std::wstring line = customerFile->readLine(); (line != L""); line = customerFile-
>readLine())
{
std::vector parts = line.split(L"t");
CustomerType tempVar2(parts[0], parts[1], parts[2]);
listOfCustomers.push_back(&tempVar2);
}
delete customerFile;
}
catch (const IOException &e)
{
System::err::print(e);
exit(-1);
}
}
CustomerType *VideoStore::getCustomer()
{
std::wcout << std::wstring(L"Enter Customer Id") << std::endl;
for (int i = 0; i < listOfCustomers.size(); i++)
{
std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") <<
listOfCustomers[i]->getFirstName() << std::endl;
}
int custId = s->nextInt();
if (custId > 0 && custId <= listOfCustomers.size())
{
return listOfCustomers[custId - 1];
}
else
{
std::wcout << std::wstring(L"Invalid Customer Id") << std::endl;
return nullptr;
}
}
VideoType *VideoStore::getVideo()
{
std::wcout << std::wstring(L"Enter Video Id") << std::endl;
for (int i = 0; i < listOfVideos.size(); i++)
{
std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") <<
listOfVideos[i]->getMovieTitle() << std::endl;
}
int videoId = s->nextInt();
if (videoId > 0 && videoId <= listOfVideos.size())
{
return listOfVideos[videoId - 1];
}
else
{
std::wcout << std::wstring(L"Invalid Video Id") << std::endl;
return nullptr;
}
}
#include
#include
#include
/*
* Driver function
*/
static void main(std::vector &a);
/*
* Show menu and ask for user choice
*/
public:
static int displyMenu();
//
//.cpp file code:
void ::main(std::vector &a)
{
createVideoList();
createCustomerList();
//
int choice = displyMenu();
while (choice != 9)
{
if (choice == 1)
{
std::wcout << std::wstring(L"Please type the exact movie Title") << std::endl;
std::wstring title = s::nextLine();
Iterator iterator = listOfVideos::begin();
bool found = false;
while (iterator->hasNext())
{
VideoType *v = iterator->next();
if (v->getMovieTitle().equals(title))
{
found = true;
std::wcout << std::wstring(L"Yes, we have this video in our store.") <<
std::endl;
break;
}
iterator++;
}
if (!found)
{
std::wcout << std::wstring(L"Sorry!! we dont have this video in our store") <<
std::endl;
}
}
else if (choice == 2)
{
CustomerType *cust = getCustomer();
VideoType *video = getVideo();
//
if (cust != nullptr && video != nullptr)
{
if (video->rentVideo(cust))
{
std::wcout << std::wstring(L"Rented successfully") << std::endl;
}
else
{
std::wcout << std::wstring(L"Can not rent. Stock not available") << std::endl;
}
}
}
else if (choice == 3)
{
CustomerType *cust = getCustomer();
VideoType *video = getVideo();
//
if (cust != nullptr && video != nullptr)
{
if (video->returnVideo(cust))
{
std::wcout << std::wstring(L"Returned Successfully") << std::endl;
}
else
{
std::wcout << std::wstring(L"Customer don't have this video") << std::endl;
}
}
}
else if (choice == 4)
{
VideoType *video = getVideo();
if (video != nullptr)
{
if (video->isAvailableInStore())
{
std::wcout << std::wstring(L"Stock available") << std::endl;
}
else
{
std::wcout << std::wstring(L"Stock Unavaiable.") << std::endl;
}
}
}
else if (choice == 5)
{
std::wcout << std::wstring(L"Title of all the videos:") << std::endl;
for (int i = 0; i < listOfVideos->size(); i++)
{
std::wcout << listOfVideos->get(i).getMovieTitle() << std::endl;
std::wcout << std::endl;
}
}
else if (choice == 6)
{
std::wcout << std::wstring(L"Title of all the videos:") << std::endl;
for (int i = 0; i < listOfVideos->size(); i++)
{
std::wcout << listOfVideos->get(i) << std::endl;
std::wcout << std::endl;
}
}
choice = displyMenu();
}
delete s;
}
int ::displyMenu()
{
std::wcout << std::wstring(L"Select one of following:") << std::endl;
std::wcout << std::wstring(L"1: To check whether store carries a particular video") <<
std::endl;
std::wcout << std::wstring(L"2: To Check out a video") << std::endl;
std::wcout << std::wstring(L"3: To Check in a video") << std::endl;
std::wcout << std::wstring(L"4: To Check whether a particular video is in stock.") <<
std::endl;
std::wcout << std::wstring(L"5: To Print only the titles of all the videos") << std::endl;
std::wcout << std::wstring(L"6: To print a list of all the videos") << std::endl;
std::wcout << std::wstring(L"9: to exit") << std::endl;
int result = s::nextInt();
return result;
}
Solution
Stack :-
void VideoStore::createVideoList()
{
try
{
BufferedReader *videoFile = nullptr;
FileReader tempVar(L"videos.txt");
videoFile = new BufferedReader(&tempVar);
videoFile->readLine(); // to flush comment line
for (std::wstring line = videoFile->readLine(); (line != L""); line = videoFile-
>readLine())
{
std::vector parts = line.split(L"t");
VideoType tempVar2(parts[0], parts[1], parts[2], parts[3], std::stoi(parts[4]));
listOfVideos.push_back(&tempVar2);
}
delete videoFile;
}
above code declare a object for BufferReader and points to null
created one temp obj which points to video file and then it is assigned to videotype object of
BufferedReader
it reads the video or we can say it stores the video in parts an then it uses the push function of
stack
Pointer : - everywhere in program it is easily seen pointer and their reference type are used
Searching: - linear search is used to find particular video present in store and same for customer
object oriented programming approach used by defining getter and setter for all declared variable
2. algorithm used to search the list for a particular video and the time complexity of the
algorithm
VideoType *VideoStore::getVideo()
{
std::wcout << std::wstring(L"Enter Video Id") << std::endl;
for (int i = 0; i < listOfVideos.size(); i++)
{
std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") <<
listOfVideos[i]->getMovieTitle() << std::endl;
}
int videoId = s->nextInt();
if (videoId > 0 && videoId <= listOfVideos.size())
{
return listOfVideos[videoId - 1];
}
else
{
std::wcout << std::wstring(L"Invalid Video Id") << std::endl;
return nullptr;
}
}
it shows the list of videos and ask the id of video
it checks if the id persents in the list or not by comparing it videoId > 0 && videoId <=
listOfVideos.size()
if id presents between 0 to size of list then it will return the list of video
Complexity :-
for (int i = 0; i < listOfVideos.size(); i++)
{
std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") <<
listOfVideos[i]->getMovieTitle() << std::endl;
}
takes --- > O(N)
if (videoId > 0 && videoId <= listOfVideos.size())
{
return listOfVideos[videoId - 1];
}
else
{
std::wcout << std::wstring(L"Invalid Video Id") << std::endl;
return nullptr;
}
second step takes O(1) time
total Complexity will be O(N)+O(1) = O(N)
algorithm has O(N) Complexity

More Related Content

Similar to Reveiwing the following code please answer the following questions.pdf

Building a Native Camera Access Library - Part I.pdf
Building a Native Camera Access Library - Part I.pdfBuilding a Native Camera Access Library - Part I.pdf
Building a Native Camera Access Library - Part I.pdfShaiAlmog1
 
Advanced AV Foundation (CocoaConf, Aug '11)
Advanced AV Foundation (CocoaConf, Aug '11)Advanced AV Foundation (CocoaConf, Aug '11)
Advanced AV Foundation (CocoaConf, Aug '11)Chris Adamson
 
Vue JS @ MindDoc. The progressive road to online therapy
Vue JS @ MindDoc. The progressive road to online therapyVue JS @ MindDoc. The progressive road to online therapy
Vue JS @ MindDoc. The progressive road to online therapyDarío Blanco Iturriaga
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile DevelopmentJan Rybák Benetka
 
Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13Rob Manson
 
17 camera, media, and audio in windows phone 8.1
17   camera, media, and audio in windows phone 8.117   camera, media, and audio in windows phone 8.1
17 camera, media, and audio in windows phone 8.1WindowsPhoneRocks
 
How to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NETHow to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NETOzeki Informatics Ltd.
 
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineCocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineChris Adamson
 
Add Custom Model and ORM to Node.js
Add Custom Model and ORM to Node.jsAdd Custom Model and ORM to Node.js
Add Custom Model and ORM to Node.jsDev_Events
 
CDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCaelum
 
Can you hear me now?
Can you hear me now?Can you hear me now?
Can you hear me now?Ida Aalen
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Object Oriented Code RE with HexraysCodeXplorer
Object Oriented Code RE with HexraysCodeXplorerObject Oriented Code RE with HexraysCodeXplorer
Object Oriented Code RE with HexraysCodeXplorerAlex Matrosov
 
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84Mahmoud Samir Fayed
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...Publicis Sapient Engineering
 

Similar to Reveiwing the following code please answer the following questions.pdf (20)

Building a Native Camera Access Library - Part I.pdf
Building a Native Camera Access Library - Part I.pdfBuilding a Native Camera Access Library - Part I.pdf
Building a Native Camera Access Library - Part I.pdf
 
Advanced AV Foundation (CocoaConf, Aug '11)
Advanced AV Foundation (CocoaConf, Aug '11)Advanced AV Foundation (CocoaConf, Aug '11)
Advanced AV Foundation (CocoaConf, Aug '11)
 
Vue JS @ MindDoc. The progressive road to online therapy
Vue JS @ MindDoc. The progressive road to online therapyVue JS @ MindDoc. The progressive road to online therapy
Vue JS @ MindDoc. The progressive road to online therapy
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile Development
 
Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
17 camera, media, and audio in windows phone 8.1
17   camera, media, and audio in windows phone 8.117   camera, media, and audio in windows phone 8.1
17 camera, media, and audio in windows phone 8.1
 
Moustamera
MoustameraMoustamera
Moustamera
 
How to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NETHow to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NET
 
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineCocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
 
Add Custom Model and ORM to Node.js
Add Custom Model and ORM to Node.jsAdd Custom Model and ORM to Node.js
Add Custom Model and ORM to Node.js
 
CDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptor
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
Can you hear me now?
Can you hear me now?Can you hear me now?
Can you hear me now?
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
cuckoo_monitor.pptx
cuckoo_monitor.pptxcuckoo_monitor.pptx
cuckoo_monitor.pptx
 
Object Oriented Code RE with HexraysCodeXplorer
Object Oriented Code RE with HexraysCodeXplorerObject Oriented Code RE with HexraysCodeXplorer
Object Oriented Code RE with HexraysCodeXplorer
 
Cam Capture
Cam CaptureCam Capture
Cam Capture
 
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
 

More from eyewaregallery

in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfeyewaregallery
 
In addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdfIn addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdfeyewaregallery
 
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdfHow much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdfeyewaregallery
 
I am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfI am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfeyewaregallery
 
How do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdfHow do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdfeyewaregallery
 
how can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdfhow can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdfeyewaregallery
 
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdfGene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdfeyewaregallery
 
For each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdfFor each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdfeyewaregallery
 
Explain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdfExplain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdfeyewaregallery
 
Explain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdfExplain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdfeyewaregallery
 
discuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdfdiscuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdfeyewaregallery
 
Describe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdfDescribe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdfeyewaregallery
 
A spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdfA spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdfeyewaregallery
 
ble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdfble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdfeyewaregallery
 
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdfeyewaregallery
 
Why is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdfWhy is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdfeyewaregallery
 
Why are there bubbles in beer and champagneSolution Bubbles of .pdf
Why are there bubbles in beer and champagneSolution  Bubbles of .pdfWhy are there bubbles in beer and champagneSolution  Bubbles of .pdf
Why are there bubbles in beer and champagneSolution Bubbles of .pdfeyewaregallery
 
Which of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdfWhich of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdfeyewaregallery
 
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdfWhich ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdfeyewaregallery
 
What would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdfWhat would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdfeyewaregallery
 

More from eyewaregallery (20)

in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
 
In addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdfIn addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdf
 
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdfHow much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
 
I am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfI am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdf
 
How do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdfHow do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdf
 
how can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdfhow can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdf
 
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdfGene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdf
 
For each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdfFor each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdf
 
Explain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdfExplain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdf
 
Explain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdfExplain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdf
 
discuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdfdiscuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdf
 
Describe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdfDescribe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdf
 
A spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdfA spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdf
 
ble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdfble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdf
 
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
 
Why is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdfWhy is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdf
 
Why are there bubbles in beer and champagneSolution Bubbles of .pdf
Why are there bubbles in beer and champagneSolution  Bubbles of .pdfWhy are there bubbles in beer and champagneSolution  Bubbles of .pdf
Why are there bubbles in beer and champagneSolution Bubbles of .pdf
 
Which of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdfWhich of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdf
 
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdfWhich ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdf
 
What would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdfWhat would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdf
 

Recently uploaded

male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 

Reveiwing the following code please answer the following questions.pdf

  • 1. Reveiwing the following code please answer the following questions 1. Discuss the data structures used 2. Discuss the algorithm used to search the list for a particular video and the time complexity of the algorithm #include #include #include class VideoType { private: std::wstring movieTitle; std::wstring producer; std::wstring director; std::wstring company; int noOfCopies = 0; // public: VideoType(const std::wstring &movieTitle, const std::wstring &producer, const std::wstring &director, const std::wstring &company, int noOfCopies); // virtual std::wstring getMovieTitle(); virtual void setMovieTitle(const std::wstring &movieTitle); virtual std::wstring getProducer(); virtual void setProducer(const std::wstring &producer); virtual std::wstring getDirector(); virtual void setDirector(const std::wstring &director); virtual std::wstring getCompany(); virtual void setCompany(const std::wstring &company); virtual int getNoOfCopies(); virtual void setNoOfCopies(int noOfCopies); // /* * Rent video to customer */ virtual bool rentVideo(CustomerType *customer);
  • 2. /* * If customer has video, return it back to stock */ virtual bool returnVideo(CustomerType *cusomer); // /* * If video is available in stock */ virtual bool isAvailableInStore(); // virtual std::wstring toString() override; }; VideoType::VideoType(const std::wstring &movieTitle, const std::wstring &producer, const std::wstring &director, const std::wstring &company, int noOfCopies) { this->movieTitle = movieTitle; this->producer = producer; this->director = director; this->company = company; this->noOfCopies = noOfCopies; } std::wstring VideoType::getMovieTitle() { return movieTitle; } void VideoType::setMovieTitle(const std::wstring &movieTitle) { this->movieTitle = movieTitle; } std::wstring VideoType::getProducer() { return producer; } void VideoType::setProducer(const std::wstring &producer) { this->producer = producer;
  • 3. } std::wstring VideoType::getDirector() { return director; } void VideoType::setDirector(const std::wstring &director) { this->director = director; } std::wstring VideoType::getCompany() { return company; } void VideoType::setCompany(const std::wstring &company) { this->company = company; } int VideoType::getNoOfCopies() { return noOfCopies; } void VideoType::setNoOfCopies(int noOfCopies) { this->noOfCopies = noOfCopies; } bool VideoType::rentVideo(CustomerType *customer) { if (noOfCopies > 0) { customer->addVideo(this); noOfCopies--; return true; } return false; } bool VideoType::returnVideo(CustomerType *cusomer)
  • 4. { if (cusomer->hasVideo(this)) { cusomer->returnVideo(this); noOfCopies++; return true; } return false; } bool VideoType::isAvailableInStore() { return noOfCopies > 0? true: false; } std::wstring VideoType::toString() { return std::wstring(L"Title: ") + movieTitle + std::wstring(L" Producer: ") + producer + std::wstring(L" Director: ") + director + std::wstring(L" Company: ") + company + std::wstring(L" Stock: ") + std::to_wstring(noOfCopies); } #include #include #include "stringbuilder.h" public: CustomerType::java *import; class CustomerType { private: std::wstring firstName; std::wstring lastName; std::wstring accountNumber; std::vector rentedVideos; // public: CustomerType(const std::wstring &firstName, const std::wstring &lastName, const std::wstring &accountNumber); virtual std::wstring getFirstName();
  • 5. virtual void setFirstName(const std::wstring &firstName); virtual std::wstring getLastName(); virtual void setLastName(const std::wstring &lastName); virtual std::wstring getAccountNumber(); virtual void setAccountNumber(const std::wstring &accountNumber); // virtual void addVideo(VideoType *v); virtual std::wstring toString() override; virtual void returnVideo(VideoType *video); /* * Check if customer has a video */ virtual bool hasVideo(VideoType *video); }; #include #include class StringBuilder { private: std::wstring privateString; public: StringBuilder() { } StringBuilder(const std::wstring &initialString) { privateString = initialString; } StringBuilder(std::size_t capacity) { ensureCapacity(capacity); } wchar_t charAt(std::size_t index) { return privateString[index]; }
  • 6. StringBuilder *append(const std::wstring &toAppend) { privateString += toAppend; return this; } template StringBuilder *append(const T &toAppend) { privateString += toString(toAppend); return this; } StringBuilder *insert(std::size_t position, const std::wstring &toInsert) { privateString.insert(position, toInsert); return this; } template StringBuilder *insert(std::size_t position, const T &toInsert) { privateString.insert(position, toString(toInsert)); return this; } std::wstring toString() { return privateString; } std::size_t length() { return privateString.length(); } void setLength(std::size_t newLength) { privateString.resize(newLength); } std::size_t capacity() {
  • 7. return privateString.capacity(); } void ensureCapacity(std::size_t minimumCapacity) { privateString.reserve(minimumCapacity); } StringBuilder *remove(std::size_t start, std::size_t end) { privateString.erase(start, end - start); return this; } StringBuilder *replace(std::size_t start, std::size_t end, const std::wstring &newString) { privateString.replace(start, end - start, newString); return this; } private: template static std::wstring toString(const T &subject) { std::wostringstream ss; ss << subject; return ss.str(); } }; CustomerType::CustomerType(const std::wstring &firstName, const std::wstring &lastName, const std::wstring &accountNumber) { this->firstName = firstName; this->lastName = lastName; this->accountNumber = accountNumber; } std::wstring CustomerType::getFirstName() { return firstName;
  • 8. } void CustomerType::setFirstName(const std::wstring &firstName) { this->firstName = firstName; } std::wstring CustomerType::getLastName() { return lastName; } void CustomerType::setLastName(const std::wstring &lastName) { this->lastName = lastName; } std::wstring CustomerType::getAccountNumber() { return accountNumber; } void CustomerType::setAccountNumber(const std::wstring &accountNumber) { this->accountNumber = accountNumber; } void CustomerType::addVideo(VideoType *v) { rentedVideos.push_back(v); } std::wstring CustomerType::toString() { StringBuilder *s = new StringBuilder(); s->append(std::wstring(L"Name: ") + firstName + std::wstring(L" ") + lastName + std::wstring(L" Account Number: ") + accountNumber + std::wstring(L" Rented Videos : ")); std::vector::const_iterator i = rentedVideos.begin(); while (i != rentedVideos.end()) { s->append(*i.getMovieTitle()); s->append(L" ");
  • 9. i++; } // return s->toString(); // } void CustomerType::returnVideo(VideoType *video) { rentedVideos.remove(video); } bool CustomerType::hasVideo(VideoType *video) { if (rentedVideos.find(video) != -1) { return true; } else { return false; } } //.h file code: #include #include #include public: VideoStore::java *import; class VideoStore { public: static std::vector listOfVideos; static std::vector listOfCustomers; static Scanner *s; /* * Read from file videos.txt and create video list */
  • 10. static void createVideoList(); /* * Read from file customers.txt and create Customer list */ static void createCustomerList(); /* * Prompt user to select a customer */ static CustomerType *getCustomer(); /* * Prompt user to select a video */ static VideoType *getVideo(); // std::vector VideoStore::listOfVideos; std::vector VideoStore::listOfCustomers; java::util::Scanner *VideoStore::s = new java::util::Scanner(System::in); void VideoStore::createVideoList() { try { BufferedReader *videoFile = nullptr; FileReader tempVar(L"videos.txt"); videoFile = new BufferedReader(&tempVar); videoFile->readLine(); // to flush comment line for (std::wstring line = videoFile->readLine(); (line != L""); line = videoFile- >readLine()) { std::vector parts = line.split(L"t"); VideoType tempVar2(parts[0], parts[1], parts[2], parts[3], std::stoi(parts[4])); listOfVideos.push_back(&tempVar2); } delete videoFile; } catch (const IOException &e)
  • 11. { System::err::print(e); exit(-1); } } void VideoStore::createCustomerList() { try { BufferedReader *customerFile = nullptr; FileReader tempVar(L"customers.txt"); customerFile = new BufferedReader(&tempVar); customerFile->readLine(); // to flush comment line for (std::wstring line = customerFile->readLine(); (line != L""); line = customerFile- >readLine()) { std::vector parts = line.split(L"t"); CustomerType tempVar2(parts[0], parts[1], parts[2]); listOfCustomers.push_back(&tempVar2); } delete customerFile; } catch (const IOException &e) { System::err::print(e); exit(-1); } } CustomerType *VideoStore::getCustomer() { std::wcout << std::wstring(L"Enter Customer Id") << std::endl; for (int i = 0; i < listOfCustomers.size(); i++) { std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") << listOfCustomers[i]->getFirstName() << std::endl; }
  • 12. int custId = s->nextInt(); if (custId > 0 && custId <= listOfCustomers.size()) { return listOfCustomers[custId - 1]; } else { std::wcout << std::wstring(L"Invalid Customer Id") << std::endl; return nullptr; } } VideoType *VideoStore::getVideo() { std::wcout << std::wstring(L"Enter Video Id") << std::endl; for (int i = 0; i < listOfVideos.size(); i++) { std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") << listOfVideos[i]->getMovieTitle() << std::endl; } int videoId = s->nextInt(); if (videoId > 0 && videoId <= listOfVideos.size()) { return listOfVideos[videoId - 1]; } else { std::wcout << std::wstring(L"Invalid Video Id") << std::endl; return nullptr; } } #include #include #include /* * Driver function */
  • 13. static void main(std::vector &a); /* * Show menu and ask for user choice */ public: static int displyMenu(); // //.cpp file code: void ::main(std::vector &a) { createVideoList(); createCustomerList(); // int choice = displyMenu(); while (choice != 9) { if (choice == 1) { std::wcout << std::wstring(L"Please type the exact movie Title") << std::endl; std::wstring title = s::nextLine(); Iterator iterator = listOfVideos::begin(); bool found = false; while (iterator->hasNext()) { VideoType *v = iterator->next(); if (v->getMovieTitle().equals(title)) { found = true; std::wcout << std::wstring(L"Yes, we have this video in our store.") << std::endl; break; } iterator++; } if (!found) {
  • 14. std::wcout << std::wstring(L"Sorry!! we dont have this video in our store") << std::endl; } } else if (choice == 2) { CustomerType *cust = getCustomer(); VideoType *video = getVideo(); // if (cust != nullptr && video != nullptr) { if (video->rentVideo(cust)) { std::wcout << std::wstring(L"Rented successfully") << std::endl; } else { std::wcout << std::wstring(L"Can not rent. Stock not available") << std::endl; } } } else if (choice == 3) { CustomerType *cust = getCustomer(); VideoType *video = getVideo(); // if (cust != nullptr && video != nullptr) { if (video->returnVideo(cust)) { std::wcout << std::wstring(L"Returned Successfully") << std::endl; } else { std::wcout << std::wstring(L"Customer don't have this video") << std::endl; }
  • 15. } } else if (choice == 4) { VideoType *video = getVideo(); if (video != nullptr) { if (video->isAvailableInStore()) { std::wcout << std::wstring(L"Stock available") << std::endl; } else { std::wcout << std::wstring(L"Stock Unavaiable.") << std::endl; } } } else if (choice == 5) { std::wcout << std::wstring(L"Title of all the videos:") << std::endl; for (int i = 0; i < listOfVideos->size(); i++) { std::wcout << listOfVideos->get(i).getMovieTitle() << std::endl; std::wcout << std::endl; } } else if (choice == 6) { std::wcout << std::wstring(L"Title of all the videos:") << std::endl; for (int i = 0; i < listOfVideos->size(); i++) { std::wcout << listOfVideos->get(i) << std::endl; std::wcout << std::endl; } } choice = displyMenu();
  • 16. } delete s; } int ::displyMenu() { std::wcout << std::wstring(L"Select one of following:") << std::endl; std::wcout << std::wstring(L"1: To check whether store carries a particular video") << std::endl; std::wcout << std::wstring(L"2: To Check out a video") << std::endl; std::wcout << std::wstring(L"3: To Check in a video") << std::endl; std::wcout << std::wstring(L"4: To Check whether a particular video is in stock.") << std::endl; std::wcout << std::wstring(L"5: To Print only the titles of all the videos") << std::endl; std::wcout << std::wstring(L"6: To print a list of all the videos") << std::endl; std::wcout << std::wstring(L"9: to exit") << std::endl; int result = s::nextInt(); return result; } Solution Stack :- void VideoStore::createVideoList() { try { BufferedReader *videoFile = nullptr; FileReader tempVar(L"videos.txt"); videoFile = new BufferedReader(&tempVar); videoFile->readLine(); // to flush comment line for (std::wstring line = videoFile->readLine(); (line != L""); line = videoFile- >readLine()) { std::vector parts = line.split(L"t"); VideoType tempVar2(parts[0], parts[1], parts[2], parts[3], std::stoi(parts[4])); listOfVideos.push_back(&tempVar2);
  • 17. } delete videoFile; } above code declare a object for BufferReader and points to null created one temp obj which points to video file and then it is assigned to videotype object of BufferedReader it reads the video or we can say it stores the video in parts an then it uses the push function of stack Pointer : - everywhere in program it is easily seen pointer and their reference type are used Searching: - linear search is used to find particular video present in store and same for customer object oriented programming approach used by defining getter and setter for all declared variable 2. algorithm used to search the list for a particular video and the time complexity of the algorithm VideoType *VideoStore::getVideo() { std::wcout << std::wstring(L"Enter Video Id") << std::endl; for (int i = 0; i < listOfVideos.size(); i++) { std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") << listOfVideos[i]->getMovieTitle() << std::endl; } int videoId = s->nextInt(); if (videoId > 0 && videoId <= listOfVideos.size()) { return listOfVideos[videoId - 1]; } else { std::wcout << std::wstring(L"Invalid Video Id") << std::endl; return nullptr; } } it shows the list of videos and ask the id of video it checks if the id persents in the list or not by comparing it videoId > 0 && videoId <= listOfVideos.size() if id presents between 0 to size of list then it will return the list of video
  • 18. Complexity :- for (int i = 0; i < listOfVideos.size(); i++) { std::wcout << std::wstring(L"Id:") << (i << 1) << std::wstring(L"t") << listOfVideos[i]->getMovieTitle() << std::endl; } takes --- > O(N) if (videoId > 0 && videoId <= listOfVideos.size()) { return listOfVideos[videoId - 1]; } else { std::wcout << std::wstring(L"Invalid Video Id") << std::endl; return nullptr; } second step takes O(1) time total Complexity will be O(N)+O(1) = O(N) algorithm has O(N) Complexity