Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A laundry shop offers washing service to its customers. It welcomes its customers every day to bring their laundry in or take it out after

A laundry shop offers washing service to its customers. It welcomes its customers every day to bring their laundry
in or take it out after its being washed. The shop has only one washing machine that takes only 5 pieces of
clothing at a time. Once customers bring their clothing, the shop worker starts stacking it in small boxes that he
queues (the order of clothing in one box does not matter, the order of boxes is what matters). See the figure
below for illustration. If the box is full it will be loaded into the washing machine, but if the machine is full, a new
empty box is used and queued.
HSS 211 Assignment #2 Dr. Omar Almousa
Implementation (70 points):
A. Define a simple data type (struct) for clothing that has only three public member variables id,
cost, and owner. The id is a unique integer given for each clothing for identification. The cost is a
float number for the cost of the laundry. Finally, owner is a string to store the name of the owner. Save
the clothing struct in a header file and include it in linkedQueue.h file. [4 points]
To help you: The header file is created for you; you only need to insert the struct definition of
clothing (4 lines of code!).
B. To store the clothing for the next wash, a stack of clothing (a list or a queue will do, but they are too
fancy for such a purpose since no need for their extra functionalities at all). The stack maximum size must
be 5 as you can tell from the specifications above.
To help you: The file mystack.h is changed so every time a stack is created using the default
constructor then the maxStackSize is set to 5.
C. To maintain order for the stacks, define a queue of stacks, let us call it any queue of stacks of clothing Q
to make our explanation smoother.
To help you: The queue Q of stacks is defined for you in the main() function in the file called
solution.cpp in which you will add the functions described in E,F, and G below.
D. Add a member function (call it addClothing)to the class linkedQueueType. This function has a
single parameter of type clothing. The function adds the clothing to the last stack in the calling queue,
if the stack is full, the clothing will be added to a new stack that is added to the rear of the calling queue.
If the calling queue is empty, the same from previous case must occur. [16 points]
E. Add a non-member function (call it wash) that simulates washing a batch from Q. This function takes Q
as a parameter, it empties the first stack from Q (into the washing machine) and remove it from Q. If Q is
empty, the function gives the message (There is nothing to wash!! Have a nap, or start
marketing!!). If the first stack in Q is not full (has less then 5 pieces of clothing), the function gives the
messages (The only batch is not full, let us wait!). otherwise, the function prints the washed
clothing. [16 points]
F. Add a non-member function (call it print) that takes Q as a parameter, prints the details of Q. If Q is
empty, the function gives the message (). Otherwise, the function will print the details (id, owner,
price) for each clothing piece in each stack in Q. After that the function prints the number of stacks in Q.
[16 points]
G. Add a non-member function (call it bill) to show the bill for a customer by his/her name. This function
takes two parameters: Q, and the name of the customer(string). If Q is empty, a message stating that
must be shown. Otherwise, the function must summon the prices for all pieces of clothing owned by the
customer in every stack of Q in the following form (The customer Ali has 4 clothing piece(s)
that cost/s 4.05). For customer with nothing in the queue, it is fine to have zeros in the count of
pieces or the total cost. This function MUST NOT CHANGE Q neither by contents nor by nature (queue);
therefore, it is recommended to have a copy of Q inside the function, and empty the copy not the
parameter. [18 points]
HSS 211 Assignment #2 Dr. Omar Almousa
How to start:
1. Download the compressed file (start.rar) from Moodle, then extract it. It will result in a folder with 6
files: clothing.h, linkedQueue.h, solution.cpp, myStack.h, queueADT.h, and
stackADT.h.(The files in red are not to be touched!).
2. In the file clothing.h, add the definition of struct clothing as specified in (A) above to get 4
points.
3. In the file linkedQueue.h, add an implementation for addClothing function as specified in (D)
above. Remember that you need to add its prototype inside the class, and its definition outside the class.
This will get you 16 points.
4. In the file solution.cpp, do the following:
a. To get 16 points, add the non-member function wash as specified in (E) above.
b. To get more 16 points, add the non-member function print as specified in (F) above.
c. Finally, to get the last 18 points, add the non-member function bill as specified in (G) above. using c++ language

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

What are negative messages? (Objective 1)

Answered: 1 week ago