Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Chinese restaurant wants to have a computer based search system that will display a recipe for each dish. The owner of the restaurant


  • #recipe-name2 recipe body #recipe-nameN recipe body To make it simpler, we will hardcode the file name; we will assume the sh

    #poultry dish Moo Goo Gai Pan, Chicken with Mushroom, Chicken with Black Bean Source, Chicken with Oyster Source, Curry Chick

    PROGRAM DESIGN As one of the design documentation, you need to draw a class diagram using UML notation (given). Based on the

    IMPLEMENTATION It is recommended that you follow the steps below: 1. Create a text file called recipefile.txt and save it t

    Requirements To get full credit, you must follow the requirements specified below: 1. You must use the classes introduced in

    Required Work You are asked to the following to get points: 1. (19 pts) Paste your source code for class RecipeFinder in the



A Chinese restaurant wants to have a computer based search system that will display a recipe for each dish. The owner of the restaurant wants the system to be flexible in that its recipes are stored in a text file. This way, the number of dishes can be expanded by adding more entries to the text file without changing any program code. The implementation method for this application should be very similar to Example 1 in Week 9's lecture notes. The user obtains a recipe by typing its name. The program searches the recipe file for the recipe. If it is found, the content of the recipe will be displayed. Otherwise, the message of "Not found" will be displayed. The program will run continuously until the user types "stop". Initially, the program should output the following message to the DOS console (or Eclipse's output window): "Welcome to Chinese recipe search program. Enter 'stop' to end. Enter a recipe name:" The program then waits for the user input. Depending on the input, the program will either continuously offer the prompt "Enter a recipe name: " or quit (output the message "Bye!"). The recipe file is a standard text file that is organized like this: #recipe-name1 recipe body #recipe-name2 recipe body #recipe-nameN recipe body To make it simpler, we will hardcode the file name; we will assume the short text file (named recipefile.txt). The name of each recipe must be preceded by a #, and the recipe name must be on a line of its own. Preceding each recipe name with a # allows the program to quickly find the start of each recipe. Following the recipe name are any number of information lines about the recipe. However, there must be a blank line between the end of one recipe's information and the start of the next recipe. Here is the content of the recipe file: #appetizers vegetable, egg roll, mixed with cream cheese, add some Teriyaki chicken, half gallon of water. Cook 15 minutes. #chow mein white meat chicken, pork beef, shrimp, vegetable include greens, mushroom, carrots, banana, apple source, half gallon of water. Cook 15 minutes. #fried rice plain rice, pork, chicken, beef, shrimp, vegetable, vegetable, include greens, mushroom, carrots, banana, apple source, one ounce of vegetable oil. Add the oil to a wok first, using hot fire to cook the oil to hot and able to see slight smoke. Then add all the ingredients and mix them. Cook 15 minutes. #poultry dish Moo Goo Gai Pan, Chicken with Mushroom, Chicken with Black Bean Source, Chicken with Oyster Source, Curry Chicken with onion, Chicken with Pepper & Tomato, Chicken with Broccoli, Chicken with Mixed Vegetable, Sweet & Sour Chicken, Chicken with Garlic Source, Hunan Chicken, Szechuan Chicken. Steps in finishing the assignment You need to do the design before writing the code. Follow the following steps to finish the assignment. PROGRAM DESIGN As one of the design documentation, you need to draw a class diagram using UML notation (given). Based on the class diagram, you write Java source code. Your class diagram must match the Java source code. There are many complete application examples in lecture notes. You may follow the same design patterns: two-class pattern (one application class and one work class) given in the lecture notes. Particularly, you are going to design two classes with association relationship (TestRecipeFinder uses RecipeFinder). The following is the class diagram of this application. You are required to write code following this design. PROGRAM DESIGN As one of the design documentation, you need to draw a class diagram using UML notation (given). Based on the class diagram, you write Java source code. Your class diagram must match the Java source code. There are many complete application examples in lecture notes. You may follow the same design patterns: two-class pattern (one application class and one work class) given in the lecture notes. Particularly, you are going to design two classes with association relationship (TestRecipeFinder uses RecipeFinder). The following is the class diagram of this application. You are required to write code following this design. TestRecipeFinder main() RecipeFinder fName: String RecipeFinder() getsWd() searchWd() Here is some clarification to the class RecipeFinder. It contains 3 methods: the constructor will take a String parameter and use it to initialize the instance variable fName:_getSWd() has no parameter and will return a String; searchWd() will return a boolean value and take 1 String parameter. IMPLEMENTATION It is recommended that you follow the steps below: 1. Create a text file called "recipefile.txt" and save it to "C:/tmp/" directory. 2. Create a Java project (ics 141prg5) using Eclipse. 3. Create an application class "TestRecipeFinder" inside the project. This class will contain a special main() method. The following is the code for this class and you can cut and paste it to Eclipse: 1. public class TestRecipeFinder ( 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. ) public static void main(String[] args) { RecipeFinder mysaki= new RecipeFinded"C:/tmp/recipefile.txt"); String sWed: } System.out.print("Welcome to Chinese recipe search program. " + "Enter 'stop' to end. "); do ( sWird=mysabi.getSW: if !msohi.searchWd(sWod)) { } } while(sWid.compareTo("stop") != 0); System.out.print("Bye!"); System.out.println("Not found."); 4. Create a work class "RecipeFinder" inside the project (you will be asked to supply). This is the most difficulty class in this program. One thing you need to figure out is how to output the body of a recipe based on the specific knowledge of there is an empty line between the current recipe and the one following it. To help you, I offer the following segment of code (you are not required to use it) for you to use: a. w b. do { *** i. info br.readLine(); ii. if(info != null) System.out.println(info); c. } while((info != null) && (info.trim()-compareTo(" ") != 0)); d. return true; e. Requirements To get full credit, you must follow the requirements specified below: 1. You must use the classes introduced in lecture notes. Particularly, you cannot use the Scanner class to read data from keyboard or from a file. Instead, you should use Buffered Reader, FileReder, InputStreamReader. 2. Your code must match your design (the class diagram). This includes number of classes; the methods inside classes; and the relationships among these classes. 3. Put unreliable code into Java's Exception management system (proper use of try- catch construct). 4. Must use automatic file closing feature. 5. Your code must use the following test cases: Test Case 1 (non successful search): Start afresh. 1. 2. Type the recipe name "roast dog". 3. Do a screen capture of the output. Test Case 2 (successful search): 1. Start afresh. 2. Type the recipe name "fried rice". 3. Do a screen capture of the output. Test Case 3 (non successful search, then exit): Start afresh. 1. 2. Type the recipe name "roast fish". 3. Type "stop". 4. Do a screen capture of the output. Required Work You are asked to the following to get points: 1. (19 pts) Paste your source code for class RecipeFinder in the space below (make sure that your code works appropriately, the source code format conforms to Java conventions (with appropriate indentations, you may lose points for not indent appropriately)): SUPPLY THE SOURCE CODE OF RECIPEFINDER CLASS IN THE SPCE BELOW TO SCORE YOUR POINTS: 2. Screen captures of run outputs. You must use the test cases given in the requirement section and there are three cases (21 pts) SUPPLY THE CHANGED SOURCE CODE FOR CASE 6 AND OUTPUT THAT PROVES THIS IN THE SPCE BELOW TO SCORE YOUR POINTS: Output for Test Case 1 (non successful search): Output for Test Case 2 (successful search): Output for Test Case 3 (non successful search, then exit):

Step by Step Solution

3.42 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Answer Java code import javaioFile import javaioFileNotFoundException import javautilScanner public ... 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

Data Analysis And Decision Making

Authors: Christian Albright, Wayne Winston, Christopher Zappe

4th Edition

538476125, 978-0538476126

More Books

Students also viewed these Computer Engineering questions

Question

Avoid evasiveness. Be direct with your answers when possible.

Answered: 1 week ago