homework代写 | c++作业 | assignment |c++代写 | c语言代写 – CS 162- 020 Assignment # 2 The Pizza Portal

CS 162- 020 Assignment # 2 The Pizza Portal

homework代写 | arm作业 | assignment | c++ – 这道题目是利用c++进行的编程代写任务, 是比较典型的c++等代写方向, 该题目是值得借鉴的assignment代写的题目

Goals:

  • Practice good software engineering design principles: o Design your solution before writing the program o Develop test cases before writing the program
  • Practice Object-Oriented Programming
  • Implement Has-a relationship using class composition
  • Use file I/O to read from and write to files
  • Practice file separation and create Makefile
  • Use functions to modularize code to increase readability and reduce repeated code

Problem Statement:

This program is going to simulate some of the common functionality of a pizza ordering site. The program will allow customers and employees to interact with the site and will begin by prompting the user to identify themselves (customer or employee).

If the user is an employee, they need to successfully log in to be able to change aspects of the site. Upon successful log in, employees should be provided the option to change the restaurant hours, add or remove items from the menu, or view or remove orders.

If the user is a customer, they should be provided with the option to search the menu by price or by ingredients (case insensitive) or place an order. When placing an order, a customer may select off the entire menu or from the last search result they examined.

Both kinds of users should have the option to view the menu, the restaurant hours, address or phone number. Users may also log out at anytime which will return them to the welcome prompt. From the welcome prompt they can end the program or log in as another user.

Requirements:

To save time on this assignment, the restaurant information, menu, and employees of the restaurant will be read in from files. Changes to the menu, hours, and the orders will be written back out to their respective files. The file formats can be found at the end of this document. You may assume that the filenames are hardcoded as follows:

menu.txt
employee.txt
restaurant_info.txt
orders.txt

You will implement this program with the following classes and structs: Classes: Restaurant, Menu, Pizza, Structs: employee, hours.

Partial outlines of the classes and structs are provided at the end of this document to help get you started. You will need to add more functions. You may add variables if they are useful and you can defend their addition.

Your code must be written in a modular format with separate .h and .cpp files for each class.

Example Operation

The following snippet of text shows an example implementation of the Pizza Portal program. Note that this example does not illustrate all required behavior. You must read this entire document to ensure that you meet all of the program requirements. (User inputs are highlighted)

<Note: The example output from this assignment is made-up. The expected output will depend on the particular input files. Your implementation does not have to look exactly the same but IT must support the required functionality as described in the assignment.>

$ ./pizza_portal
Welcome to Bytes Pizza!
Are you a customer (C) or employee (E) or would you like to quit (Q)? E
Please enter your ID number: 1111
Please enter your password: Flam
Incorrect ID or password. Please try again.
Please enter your ID number: 1111
Please enter your password: Flamingo
Welcome C.J. Cregg!
What would you like to do?
  1. Change hours
  2. View orders
  3. Remove order
  4. Add Item to Menu
  5. Remove Item from Menu
  6. View Menu
  7. View Hours
  8. View Address
  9. View Phone
  10. Log out Selection: 1

Which day would you like to change the hours for? Friday What should the opening time be? 8am What should the closing time be? 11pm Here are the updated hours: Sunday 12pm 8pm Monday 10am 9pm Tuesday 10am 9pm Wednesday 10am 9pm Thursday 10am 9pm Friday 8am 11pm Saturday 10am 11pm

What would you like to do?

  1. Change hours
  2. View orders
  3. Remove order
  4. Add Item to Menu
  5. Remove Item from Menu
  6. View Menu
  7. View Hours
  8. View Address
  9. View Phone
  10. Log out Selection: 10

Welcome to Bytes Pizza! Are you a customer (C) or employee (E) or would you like to quit (Q)? C What would you like to do?

  1. View Menu
  2. Search by Cost
  3. Search by Ingredients
  4. Place Order
  5. View Hours
  6. View Address
  7. View Phone
  8. Log out Selection: 3

Would you like to search for ingredients you want include (I) or exclude (E)? I What item would you like to include? pepperoni Do you want to include another item (Yes/No)? Yes What item would you like to include? mozzarella Do you want to include another item? No Here are the pizzas that match your criteria: Corvegas 12 23 28 5 Pesto Pepperoni Mozzarella Roasted_Red_Peppers Artichoke Meat_Lovers 10 18 25 6 Pepperoni Sausage Smoked_Pork_Belly Mozzarella P arm Marinara

Would you like to reduce your search by excluding some ingredients (Yes/No)? No Would you like to place an order off this search result (Yes/No)? No

What would you like to do?

  1. View Menu
  2. Search by Cost
  3. Search by Ingredients
  4. Place Order
  5. View Hours
  6. View Address
  7. View Phone
  8. Log out Selection: 2

What is your maximum budget (in dollars)? 20 Here are the pizzas that match your criteria. Ineligible sizes are marked as N/A: Corvegas 12 N/A N/A 5 Pesto Pepperoni Mozzarella Roasted_Red_Peppers Artichoke Zorba 12 N/A N/A 5 Herb_Chicken Feta Artichoke Red_onion Mushroom Meat_Lovers 10 18 N/A 6 Pepperoni Sausage Smoked_Pork_Belly Mozzarella Parm Marinara Southtown_Blues 9 17 20 7 Pear Apple Bleu_Cheese Mozzarella Toasted_Almonds Sweet_Onion Garlic_Infused_Oil Margherita 9 17 N/A 5 Tomato Mozzarella_Fresca Basil Marinara Balsamic_Reduction

Would you like to place an order off this search result (Yes/No)? Yes (1) Small Corvegas – $ (2) Small Zorba – $ (3) Small Meat_Lovers – $ (4) Medium Meat_Lovers – $ (5) Small Southtown_Blues – $ (6) Medium Southtown_Blues – $ (7) Large Southtown_Blues – $ (8) Small Margherita – $ (9) Medium Margherita – $ Please select an option from the list above. You may also enter 0 to cancel this order or press enter (blank line) to proceed to checkout. Your selection: 5 How many Small Southtown_Blues? 2 Please select an option from the list above. You may also enter 0 to cancel this order or press enter (blank line) to proceed to checkout. Your selection: 4 How many Medium Meat_Lovers? 1 Please select an option from the list above. You may also enter 0 to cancel this order or press enter (blank line) to proceed to checkout. Your selection: Please provide the following information: Customer name: Roger

Credit card number: 1111222233334444 Phone number: 9998887777 Thank you! Your order number is 2.

< Note that the orders.txt file would now contain an additional entry with the new order. The format would follow the example shown in the “Required File Formats” section.>

What would you like to do?

  1. View Menu
  2. Search by Cost
  3. Search by Ingredients
  4. Place Order
  5. View Hours
  6. View Address
  7. View Phone
  8. Log out Selection: 1

Here is our menu: The_Bent 21 25 30 6 Cheese Pepperoni American_Bacon Italian_Sausage Black_Olives Mushroom Corvegas 12 23 28 5 Pesto Pepperoni Mozzarella Roasted_Red_Peppers Artichoke Zorba 12 23 28 5 Herb_Chicken Feta Artichoke Red_onion Mushroom Meat_Lovers 10 18 25 6 Pepperoni Sausage Smoked_Pork_Belly Mozzarella Parm Marinara Southtown_Blues 9 17 20 7 Pear Apple Bleu_Cheese Mozzarella Toasted_Almonds Sweet_Onion Garlic_Infused_Oil Margherita 9 17 24 5 Tomato Mozzarella_Fresca Basil Marinara Balsamic_Reduction

What would you like to do?

  1. View Menu
  2. Search by Cost
  3. Search by Ingredients
  4. Place Order
  5. View Hours
  6. View Address
  7. View Phone
  8. Log out Selection: 4

(1) Small The_Bent – $ (2) Medium The_Bent – $ (3) Large The_Bent – $ (4) Small Corvegas – $ (5) Medium Corvegas – $ 23 (6) Large Corvegas – $ 28 (7) Small Zorba – $ (8) Medium Zorba $ (9) Large Zorba – $

(10) Small Meat_Lovers - $
(11) Medium Meat_Lovers - $
(12) Large Meat_Lovers  $
(13) Small Southtown_Blues - $
(14) Medium Southtown_Blues - $
(15) Large Southtown_Blues - $
(16) Small Margherita - $
(17) Medium Margherita - $
(18) Large Margherita - $
Please select an option from the list above. You may also enter 0 to
cancel this order or press enter (blank line) to proceed to checkout.
Your selection: <Enter>
Error! Nothing is on your order list!!
Please select an option from the list above. You may also enter 0 to
cancel this order or press enter (blank line) to proceed to checkout.
Your selection: 0
What would you like to do?
  1. View Menu
  2. Search by Cost
  3. Search by Ingredients
  4. Place Order
  5. View Hours
  6. View Address
  7. View Phone
  8. Log out Selection: 8
Welcome to Bytes Pizza!
Are you a customer (C) or employee (E) or would you like to quit (Q)? Q
Bye!

Implementation Requirements:

  • This list is not exhaustive. Your program must satisfy all the requirements given in this document
  • You are NOT expected to validate company information that is provided. There are many valid forms of addresses, hours of operation, etc.
  • Each class needs accessor functions, mutator functions, constructors, copy constructor, destructors, assignment operator overload, and use of const where appropriate.
  • The program needs to be compiled with a makefile
  • Files must be separated into a .h and a .cpp for each class. Both structs may occur in the same .h You should have one driver file.
  • Text files will be provided for demos. You may use the examples ones provided in this document to test your program.
  • If an employee provides incorrect login information, the system should re-prompt until they get it right or elect to quit.
  • Users should be provided their menu of choices after each completed task.
  • When text files are edited, they should be saved with their newest version. At the completion of your program there should only be four .txt files.
  • Users should have the option of refining their search when they search by ingredients. This means if they first search for ingredients to include on the pizza, then they may further reduce these results by providing a list of ingredients to exclude. Likewise, if start with ingredients to exclude, they may refine the results by providing a list of ingredients to include. Users should then be able to place an order after completing this search.
  • Users should be able to place an order after completing the cost search. The program does not need to refine the search after finding pizzas by cost.

Required Structs, Classes and File Formats

Please download the tar archive to start. Command to download: wget http://classes.engr.oregonstate.edu/eecs/spring2020/cs162-020/assignments/assign2.tar Command to extract: tar -xvf assign2.tar

The structs and classes in the tar archive above are required to be used in your implementation. Note that you are allowed to add additional member functions as needed. You may add member variables if you can justify their existence.

For each .h in the tar archive, you will have to create its corresponding .cpp file.

Besides, your program must accommodate the file formats as specified in this section. (Example .txt files are also provided in the tar archive above)

The menu.txt file will have the following pattern: Pizza_name Small_Cost Medium_Cost Large_Cost Num_Ingredients Ingredients … ……

The employee.txt file will have the following pattern: (Updated) ID Password First_Name Last_Name ……

The restaurant_info.txt file will have the following pattern: (Updated) Name Phone Number in format: (555) 543- 8765 Address Sunday Open_time Close_time Monday Open_time Close_time Tuesday Open_time Close_time Wednesday Open_time Close_time Thursday Open_time Close_time Friday Open_time Close_time Saturday Open_time Close_time

The orders.txt file must follow the pattern shown below. The “size” must be stored as S, M, or L, representing small, medium, or large, respectively. The customer phone number must be stored without spaces or hyphenation (e.g. 8009776368 ). (Updated)

<Number of orders in file>
Order_Num Customer_Name Customer_CC Customer_Phone Pizza_name size quantity
<repeat for each distinct pizza on order>
Order_Num Customer_Name Customer_CC Customer_Phone Pizza_name size quantity
<repeat for each distinct pizza on order>
...<Repeats for each individual order>...

Programming Style/Comments

In your implementation, make sure that you include a program header. Also ensure that you use proper indentation/spacing and include comments! Below is an example header to include. Make sure you review the style guidelines for this class , and begin trying to follow them, i.e. dont align everything on the left or put everything on one line!

/******************************************************
** Program: pizza_portal.cpp
** Author: Your Name
** Date: 04/ 20 /20 20
** Description:
** Input:
** Output:
******************************************************/

Extra Credit: Work with a different file format

In real practice, the .txt files will not contain a number at the top, indicating the number of entries within the file. As a programmer, it is your job to figure out the number of entries in the file before reading information in. With that being said, the txt files in this tar archive will not contain the number at front. You will earn extra credits if your program is able to work with this type of files. (*Note: you only need to choose one file format, either with or without the leading number in the files, not both)

Design Document  Due Sunday 4/ 19 /2020, 11:59pm on Canvas
Refer to the Example Design Document  Example_Design_Doc.pdf

Understanding the Problem/Problem Analysis:

  • What are the user inputs, program outputs, etc.?
  • What assumptions are you making?
  • What are all the tasks and subtasks in this problem?

Program Design:

  • What does the overall big picture of each function look like? (Flowchart or pseudocode) o What member variables do you need to create for each class? o What member functions do you need to create for each class? o How do classes interact with each other? (How do you implement a has-a relationship?) o How to read from a file, and store information into your program? o How to write information from your program to a file? o How would you modularize the program?
  • What kind of bad input are you going to handle?

Based on your answers above, list the specific steps or provide a flowchart of what is needed to create. Be very explicit!!!

Program Testing: Create a test plan with the test cases (bad, good, and edge cases). What do you hope to be the expected results?

  • What are the good, bad, and edge cases for ALL input in the program? Make sure to provide enough of each and for all different inputs you get from the user.

Electronically submit your Design Doc (.pdf file!!!) by the design due date, on Canvas.

Program Code  Due Sunday, 4 / 26 /2020, 11:59pm on TEACH

Additional Implementation Requirements:

  • Your user interface must provide clear instructions for the user and information about the data being presented
  • Your program must catch all required errors and recover from them.
  • You are not allowed to use libraries that are not introduced in class, more specifically, you may not use the library in your program. Any searching or sorting functionality must be implemented “manually” in your implementation.
  • Your program should be properly decomposed into tasks and subtasks using functions. To help you with this, use the following: o Make each function do one thing and one thing only. o No more than 15 lines inside the curly braces of any function, including main(). Whitespace, variable declarations, single curly braces, vertical spacing, comments, and function headers do not count. o Functions over 15 lines need justification in comments. o Do not put multiple statements into one line.
  • No global variables allowed (those declared outside of many or any other function, global constants are allowed).
  • No goto function allowed
  • No vectors allowed
  • You must not have any memory leaks
  • You program should not have any runtime error, e.g. segmentation fault
  • Make sure you follow the style guidelines, have a program header and function headers with appropriate comments, and be consistent.

Compile and Submit your assignment

When you compile your code, it is acceptable to use C++11 functionality in your program. In order to support this, change your Makefile to include the proper flag.

For example, consider the following approach (note the inclusion of – std=c++11 ):

g++ - std=c++11 <other flags and parameters>

In order to submit your homework assignment, you must create a tarred archive that contains your .h, .cpp, and Makefile files. This tar file will be submitted to TEACH. In order to create the tar file, use the following command:

tar cvf assign 2 .tar <list of all .h and .cpp files> Makefile

You do not need to submit the txt files. The TAs will have their own for grading.

Remember to sign up with a TA to demo your assignment. The deadline of demoing this assignment without penalties is 5 / 10 /2020.