You are working for Nile, a small startup selling books online with dreams of becoming a huge international company whic

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

You are working for Nile, a small startup selling books online with dreams of becoming a huge international company whic

Post by answerhappygod »

You are working for Nile, a small startup selling books online
with dreams of becoming a huge international company which sells
everything (maybe you’ll even get into cloud computing). The
company currently has a system for processing Order objects which
contain a collection of Book objects which are part of that order.
In the past the company has been focused on scaling its order
fulfillment process to keep up with the huge number of orders, but
now they want to focus on better predicting what types of books are
popular over time so they can better manage ordering from their
suppliers so they have the book in stock when they need them (but
not more than they need). As a proof of concept they want you to
analyze the books being shipped by category so they can get an idea
of what types of analysis will be possible.
Unfortunately, the Book objects encode their category (fiction,
biography, romance, etc.) through their concrete subclass under a
Book interface class. This was done because each category of book
is organized slightly differently in the warehouse, so the
fulfillment instructions in the Book object are overridden in the
concrete subclass. This means you’ll need to create a visitor
pattern in order to determine the types/categories of all the Book
objects which are ordered. Another developer has added a function
call analyze(vector orders) to the order processing pipeline so
each batch of orders will be passed to this function before being
packed and shipped, this function should return the object that you
use to perform the analysis which is why its missing the return
type.
Your task is to create a visitor which processes all the Book
objects in each order and determines what percentage of the total
books in the current batch of orders each category of books
represents. You’ll need to create the analysis system which
performs the analysis and is capable of reporting the results
through method(s). You will also need to implement the
analyze(vector orders)function so that it uses this new analysis
system, and add any necessary functions to the existing classes so
they can be analyzed. Note that the maintainers of the Book classes
don’t want you to add any members to the Book classes, but adding
methods is fine (lets just blame office politics). You do not need
to worry about constructors or destructors for the new class you
are developing.
ORDER CLASS
class Order
{
private:
vector books;
string shipping_address;
public:
Book* get_books_at(int i) { return this->books.at(i);
}
int get_books_size() { return this->books.size();
}
string get_shipping_address() {
return
this->shipping_address; }
double get_total_price() {
double
sum = 0;
for(int
i = 0; i < this->get_books_size(); i++) {
sum
+= this->get_books_at(i)->get_price();
}
return sum;
};
BOOK CLASSES
class Book {
private:
string title;
double price;
string isbn10;
public:
string get_title() { return this->title;
}
double get_price() { return this->price;
}
string get_isbn10() { return this->isbn10;
}
string get_isbn13() { return to_isbn13(this->isbn10);
}
virtual void fulfill() = 0;
};
BOOK CLASSES
class Fiction : public Book{
public:
virtual void fulfill() { /* Fiction Specific
Implementation
*/ }
};
class Biography : public Book{
Public:
virtual void fulfill() { /* Biography Specific
Implementation
*/ }
};
class Romance : public Book{
public:
virtual void fulfill() { /* Romance Specific
Implementation
*/ }
};
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply