A Chinese restaurant wants to have a computer based search system that will display a recipe...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. \n" + "Enter 'stop' to end.\n"); 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): 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. \n" + "Enter 'stop' to end.\n"); 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):
Expert Answer:
Answer rating: 100% (QA)
Answer Java code import javaioFile import javaioFileNotFoundException import javautilScanner public ... View the full answer
Related Book For
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe
Posted Date:
Students also viewed these computer engineering questions
-
If it is found that large differences in IFRS practice exist systematically between countries, what implications does this have?
-
Accounting 4. A local Chinese restaurant wants to determine the number of dishes to be prepared before operating hours for the most popu
-
Eclipse Computer Company has been purchasing carrying cases for its portable computers at a delivered cost of $ 65 per unit. The company, which is currently operating below full capacity, charges...
-
For rigid-body motion, the strains will vanish. Under these conditions, integrate the straindisplacement relations (7.6.1) to show that the most general form of a rigid-body motion displacement field...
-
In the context of the neoclassical model, how would you interpret the imperative to "cause no harm?" Substantiate your view with two reasons and examples.
-
In Problems 125132, use a calculator to approximate each radical. Round your answer to two decimal places.
-
Identify the common requirements for a valid common law marriage.
-
The following data were taken from the income statements of Imhoff Company. Compute for each year (a) The inventory turnover and (b) Days in inventory. What conclusions concerning the management of...
-
Eve Co purchases a machine that had a list price of $10,000 on January 1, 2020 The machine has no estimated residual value and a 2 years estimated useful life. The Company is using the...
-
There is a parcel of land next to the Playful Paws, Inc. building. Ellen, the owner of this property, approached John to discuss the idea of selling it to him. John is interested. Ellen knows that...
-
Faramarzinikpey Company, a public company, is preparing its annual financial statements on December 31, 2022. The following selected information is available: 1. 2. The company has been sued by an...
-
An accounting firm has just contacted your consulting business for assistance. They want to hire someone to do accounting and payroll. The bookstore is downstairs, while the office is upstairs in an...
-
large sampling multi-volume encyclopedia like the Encyclopaedia Britannica. Describe in detail the ways in which you would organise and index the encyclopedia text, and the facilities you would offer...
-
Company C - Art had a net income of 8 million dollars in 2 0 1 5 , while a small competing company, C - Tech, had a net income of 3 million dollars the same year. The management ofC - Art develops a...
-
Olivia has $200,000 deposited today (at t = 0) in an account at the Nashua Savings Bank which pays an annual interest rate of 4.4%. If starting next year (at t = 1) she wants to start making 6 annual...
-
Why is a measure of serum lactate obtained in the initial assessment of the trauma patient?
-
The base of the square foundation, 3 mx 3 m, is located at 1 m depth. The soil supporting foundation has a friction angle of '= 20 and c'= 20 kN/m. The unit weight of soil, y, is 21 kN/m. What is the...
-
Chao, Louis, and Mari, unrelated individuals, own all of the shares of Cerise Corporation. All three shareholders have been active in the management of Cerise since its inception. In the current...
-
The Firm Chair Company manufactures customized wood furniture and sells the furniture in large quantities to major furniture retailers. Jim Bolling has recently been assigned to analyze the companys...
-
Consider a population of 2000 individuals, 800 of whom are women. Assume that 300 of the women in this population earn at least $60,000 per year, and 200 of the men earn at least $60,000 per year. a....
-
Recall that the file Baseball Salaries 2009 Extra.xlsx contains data on 818 Major League Baseball (MLB) players during the 2009 season. Use StatTools to find the mean, median, standard deviation, and...
-
Is it possible for a hydrogen nucleus to emit an alpha particle? Why? (a) yes, because alpha particles are the simplest form of radiation (b) no, because it would require the nuclear fission of...
-
Who discovered that energy and mass are two different forms of the same thing?
-
What evidence supports the contention that the strong nuclear force is stronger than the electrical interaction at short internuclear distances? (a) Protons are able to exist side by side in an...
Study smarter with the SolutionInn App