Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Files provided: Validator.html: https://blackboard.cpp.edu/bbcswebdav/pid-4361252-dt-content-rid-50772557_2/courses/18F_CBA_CIS3090.06/Validator.html Valiator.jar: https://blackboard.cpp.edu/bbcswebdav/pid-4361252-dt-content-rid-50772558_2/xid-50772558_2 orderline.txt: https://blackboard.cpp.edu/bbcswebdav/pid-4361252-dt-content-rid-50772581_2/courses/18F_CBA_CIS3090.06/orderline%281%29.txt In Java (NetBeans IDE 8.2) Files provided to you: 1) Valiator.jar and Validator.html The provided Validator.html, similar

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Files provided:

Validator.html:

https://blackboard.cpp.edu/bbcswebdav/pid-4361252-dt-content-rid-50772557_2/courses/18F_CBA_CIS3090.06/Validator.html

Valiator.jar:

https://blackboard.cpp.edu/bbcswebdav/pid-4361252-dt-content-rid-50772558_2/xid-50772558_2

orderline.txt:

https://blackboard.cpp.edu/bbcswebdav/pid-4361252-dt-content-rid-50772581_2/courses/18F_CBA_CIS3090.06/orderline%281%29.txt

In Java (NetBeans IDE 8.2)

Files provided to you: 1) Valiator.jar and Validator.html The provided Validator.html, similar to the standard Java API Specifications, shows what methods the given Validator class provides. In your NetBeans project, you need to use the provided Validator class to validate user's input so that you don't need to write your own validation program In order to use the provided Validator. jar file, download it to your computer, then add it as a library to your NetBeans project by the following procedures a) It appears that in order to use the Validator.jar in your NetBeans project, the package for your source code must be default package, refer to the following screenshot. Project - NetBeans IDE 8.2 Ei Ec Yi Nav So Refa B De Prc Tefo Win He- Search (Ctri+ b) After you create the Java project in NetBeans, right click Libraries, click Add JAR/Folder..., then choose the Validator.jar file from your computer 2) orderline.txt: a sample output file. The provided text file is for your reference, such as to show the format of its content, and your program needs to write output to this file. If this file does not exist yet, your program needs to create it dynamically Requirements description Assume you work part-time at a sandwich store. As the only employee who knows java programming you help to write a sandwich ordering application for the store The following is a requirement description with some sample output. 1. Selecting bread (5 points) When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a bread by entering a corresponding integer number. A sample output is as follows. Select Sandwich Bread 1 White Bread $1.5 2 Wheat Bread $1.6 3 French Bread $1.8 4 Organic Bread $2.0 Select a bread [1, 4] If the user enters an integer number not between1 and 4, the user will see an error message and the input verification is done by using the provided Validator class (from Validator.jar). A sample output for invalid number is as follows Select a bread [1, 4]: 0 Error! Number must be greater than 0 Select a bread [1, 4]: In your program, you can hard-code the information for sandwich breads (i.e., bread names and prices) shown above, such as "1 White Bread $1.5" and use the hard-code price, such as 1.5, for calculation of a total price of the order 2. Selecting vegetables (10 points) After the user provides a right number for bread selection, the program asks the user to select vegetables. A sample output is as follows. Again, input validation is needed and is provided by the Validator class (from Validator.jar). =-= select Sandwich Vegetables : 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.50 8 Quit vegetable selection Select vegetables: [1, 8]: You hard-code the vegetables information as shown above, such as "1 red onions $0.10" and use the hard-code price, such as 0.10, for calculation of the total price of the order. After the user makes a choice for vegetable, such as 2 for olives. The program continues asking for selecting a vegetable so that the user can have multiple vegetables for one sandwich. The user can enter "8" to quit vegetable selection. A sample output is as follows. Select Sandwich Vegetables: 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.50 8 Quit vegetable selection Select vegetables [, 8] 2 =-= select Sandwich Vegetables : - 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.50 8 Quit vegetable selection Select vegetables [1, 81: 3. Selecting meat (5 points) After vegetable selection, the program shows meat selection. A sample output is as follows. =-= select Sandwich Vegetables : 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.49 8 Quit vegetable selection Select vegetables: , 8] 8 Select Sandwich Meat: 1 Ham $1.0 2 Roasted Chicken Breast $1.1 3 Turkey Breast $1.2 4 Roast Beef $1.5 5 Quit meat selection Select meat [1, 5 Input validation is needed and works as before. Unlike vegetable selection which allows selecting multiple vegetables, meat selection does not repeat after the user enters a valid number between 1 and You hard-code the information for meat shown above, such as I price, such as 1.0, for calculation of the total price of the order Ham $1 . 0" and use the hard-code 4. Entering a customer's name (5 points) After making a meat selection, the program asks for the user's name so that the user can enter a name like John or John Smith Select Sandwich Meat: 1 Ham $1.0 2 Roasted Chicken Breast $1.1 3 Turkey Breast $1.2 4 Roast Beef $1.5 5 Quit meat selection Select meat [1, 51: 4 Enter customer's name John Smith 5. Displaying and writing order line information (15 points) After entering a customer name, the program prints details for this order in computer monitor. The information includes the following six fields: date and time, customer name, bread, vegetable(s), meat, and a (formatted) total price, and each field is separated by a tab. A sample output to the monitor is as follows Enter customer's name John Smith Jul 6, 2016 10:35:43 AM John Smith Organic Bread lettuce, tomatoes, green peppers Roast Beef $4.25 Continue to order more sandwich? (y) For your reference, the date and time is created by the following statements Date now new Date) Date Format defaultDate = DateFormat .getDateTimeInstance(Date Format. MEDIUM, DateFormat.MEDIUM); String time defaultDate.format(now); Multiple vegetables are separated by commas Besides showing on monitor, the same order content is written (appended) to a text file named orderline.txt and each order occupies one line in the text file. Here is a specific example for an order in the orderline.tx 2016/07/05 20:34:17 John Smith Organic Bread lettuce, tomatoes, green peppers Roast Beef $4.25 Your program needs to create the output file, named orderline.txt, if it doesn't exist yet, and later appends (not overwrite) order information to the file. So next time when your program is executed, new order information will be appended to the orderline.txt file. You must use a relative path when creating an output stream writer object. For simplicity, we don't record any information about the sales clerk and one order includes only one sandwich. 6. Repeating the order process (5 points) Continue to order more sandwich? (y): If the user enters y or Y in the above prompt, the whole order process repeats by asking the user to select a sandwich bread, vegetable(s), meat, and enter a customer name, and write the order content to file, etc Design requirements: (5 points) You must have at least the following java classes. You may have additional classes if you want [1] Sandwich class simulates the sandwich entity in real world. It has attributes of bread, vegetables meat, and price of the sandwich, and corresponding methods. and the string value for time stamp (refer to the prior sample code) the passed-in order's content to the output text file, orderline.txt. [2] Order class simulates the order. This class has attributes of a customer name, a sandwich object, [3] SandwichIO class provides a static method, writeOrderToFile(Order). This method appends the 4 [4] SandwichApp is the Java application that has the main method. This class interacts with Sandwich, Order, SandwichIO, and the provided Validator classes. Hint: In this class, once you have enough information for a sandwich, you create a Sandwich object; once you have enough information for an order, you create an Order object; and then call the static method from SandwichIO to write the content of the order to the orderline.txt file Suggestions: Start early and start from simple. For example, leaving the multiple vegetable selections, the order repeat process, and writing to file, etc, to a later stage. When incrementally improving your programs, make sure to keep a clean copy of your completed program. In case you couldn't complete the whole project in time, you can still submit a working solution of partial project and receive partial points. Files provided to you: 1) Valiator.jar and Validator.html The provided Validator.html, similar to the standard Java API Specifications, shows what methods the given Validator class provides. In your NetBeans project, you need to use the provided Validator class to validate user's input so that you don't need to write your own validation program In order to use the provided Validator. jar file, download it to your computer, then add it as a library to your NetBeans project by the following procedures a) It appears that in order to use the Validator.jar in your NetBeans project, the package for your source code must be default package, refer to the following screenshot. Project - NetBeans IDE 8.2 Ei Ec Yi Nav So Refa B De Prc Tefo Win He- Search (Ctri+ b) After you create the Java project in NetBeans, right click Libraries, click Add JAR/Folder..., then choose the Validator.jar file from your computer 2) orderline.txt: a sample output file. The provided text file is for your reference, such as to show the format of its content, and your program needs to write output to this file. If this file does not exist yet, your program needs to create it dynamically Requirements description Assume you work part-time at a sandwich store. As the only employee who knows java programming you help to write a sandwich ordering application for the store The following is a requirement description with some sample output. 1. Selecting bread (5 points) When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a bread by entering a corresponding integer number. A sample output is as follows. Select Sandwich Bread 1 White Bread $1.5 2 Wheat Bread $1.6 3 French Bread $1.8 4 Organic Bread $2.0 Select a bread [1, 4] If the user enters an integer number not between1 and 4, the user will see an error message and the input verification is done by using the provided Validator class (from Validator.jar). A sample output for invalid number is as follows Select a bread [1, 4]: 0 Error! Number must be greater than 0 Select a bread [1, 4]: In your program, you can hard-code the information for sandwich breads (i.e., bread names and prices) shown above, such as "1 White Bread $1.5" and use the hard-code price, such as 1.5, for calculation of a total price of the order 2. Selecting vegetables (10 points) After the user provides a right number for bread selection, the program asks the user to select vegetables. A sample output is as follows. Again, input validation is needed and is provided by the Validator class (from Validator.jar). =-= select Sandwich Vegetables : 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.50 8 Quit vegetable selection Select vegetables: [1, 8]: You hard-code the vegetables information as shown above, such as "1 red onions $0.10" and use the hard-code price, such as 0.10, for calculation of the total price of the order. After the user makes a choice for vegetable, such as 2 for olives. The program continues asking for selecting a vegetable so that the user can have multiple vegetables for one sandwich. The user can enter "8" to quit vegetable selection. A sample output is as follows. Select Sandwich Vegetables: 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.50 8 Quit vegetable selection Select vegetables [, 8] 2 =-= select Sandwich Vegetables : - 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.50 8 Quit vegetable selection Select vegetables [1, 81: 3. Selecting meat (5 points) After vegetable selection, the program shows meat selection. A sample output is as follows. =-= select Sandwich Vegetables : 1 red onions $0.05 2 olives $0.10 3 pickles $0.10 4 lettuce $0.20 5 green peppers $0.25 6 tomatoes $0.30 7 cheese $0.49 8 Quit vegetable selection Select vegetables: , 8] 8 Select Sandwich Meat: 1 Ham $1.0 2 Roasted Chicken Breast $1.1 3 Turkey Breast $1.2 4 Roast Beef $1.5 5 Quit meat selection Select meat [1, 5 Input validation is needed and works as before. Unlike vegetable selection which allows selecting multiple vegetables, meat selection does not repeat after the user enters a valid number between 1 and You hard-code the information for meat shown above, such as I price, such as 1.0, for calculation of the total price of the order Ham $1 . 0" and use the hard-code 4. Entering a customer's name (5 points) After making a meat selection, the program asks for the user's name so that the user can enter a name like John or John Smith Select Sandwich Meat: 1 Ham $1.0 2 Roasted Chicken Breast $1.1 3 Turkey Breast $1.2 4 Roast Beef $1.5 5 Quit meat selection Select meat [1, 51: 4 Enter customer's name John Smith 5. Displaying and writing order line information (15 points) After entering a customer name, the program prints details for this order in computer monitor. The information includes the following six fields: date and time, customer name, bread, vegetable(s), meat, and a (formatted) total price, and each field is separated by a tab. A sample output to the monitor is as follows Enter customer's name John Smith Jul 6, 2016 10:35:43 AM John Smith Organic Bread lettuce, tomatoes, green peppers Roast Beef $4.25 Continue to order more sandwich? (y) For your reference, the date and time is created by the following statements Date now new Date) Date Format defaultDate = DateFormat .getDateTimeInstance(Date Format. MEDIUM, DateFormat.MEDIUM); String time defaultDate.format(now); Multiple vegetables are separated by commas Besides showing on monitor, the same order content is written (appended) to a text file named orderline.txt and each order occupies one line in the text file. Here is a specific example for an order in the orderline.tx 2016/07/05 20:34:17 John Smith Organic Bread lettuce, tomatoes, green peppers Roast Beef $4.25 Your program needs to create the output file, named orderline.txt, if it doesn't exist yet, and later appends (not overwrite) order information to the file. So next time when your program is executed, new order information will be appended to the orderline.txt file. You must use a relative path when creating an output stream writer object. For simplicity, we don't record any information about the sales clerk and one order includes only one sandwich. 6. Repeating the order process (5 points) Continue to order more sandwich? (y): If the user enters y or Y in the above prompt, the whole order process repeats by asking the user to select a sandwich bread, vegetable(s), meat, and enter a customer name, and write the order content to file, etc Design requirements: (5 points) You must have at least the following java classes. You may have additional classes if you want [1] Sandwich class simulates the sandwich entity in real world. It has attributes of bread, vegetables meat, and price of the sandwich, and corresponding methods. and the string value for time stamp (refer to the prior sample code) the passed-in order's content to the output text file, orderline.txt. [2] Order class simulates the order. This class has attributes of a customer name, a sandwich object, [3] SandwichIO class provides a static method, writeOrderToFile(Order). This method appends the 4 [4] SandwichApp is the Java application that has the main method. This class interacts with Sandwich, Order, SandwichIO, and the provided Validator classes. Hint: In this class, once you have enough information for a sandwich, you create a Sandwich object; once you have enough information for an order, you create an Order object; and then call the static method from SandwichIO to write the content of the order to the orderline.txt file Suggestions: Start early and start from simple. For example, leaving the multiple vegetable selections, the order repeat process, and writing to file, etc, to a later stage. When incrementally improving your programs, make sure to keep a clean copy of your completed program. In case you couldn't complete the whole project in time, you can still submit a working solution of partial project and receive partial points

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

discuss ethical issues concerning products

Answered: 1 week ago