Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PF1 LAB7 Designing, Creating and Using our first Java Class NOTE: Place your solution for this lab in ~/PF1/lab7/Lab7.java OBJECTIVES: 1) Further practice using the
PF1 LAB7 Designing, Creating and Using our first Java Class NOTE: Place your solution for this lab in ~/PF1/lab7/Lab7.java OBJECTIVES: 1) Further practice using the Java compiler and RTE by creating a Java application. 2) Designing, creating and using Java classes of our own. PROCEDURE: You have been promoted to Chief Technology Officer of the local Taco Bell. You have heard that there will soon be a major breakthrough in burrito making technology with the upcoming announcement of an Object Oriented Burrito Maker (OOBM). You want your Taco Bell to be on the cutting edge with this new technology. So your job is to create a program that will create burrito objects that will ultimately be delivered over a local network to the OOBM for production. For now, you are to design a "Burrito" class that will contain all of the information needed to serve up a custom made burrito. The burritos are made of beans, beef, cheese and salsa. Also, we want to associate a customer name with each burrito object that we create so that we can call them by name when the OOBM chucks their custom made burrito onto an awaiting plastic tray. Yum! Your Burrito class should provide: 1) A constructor that will create a "default" burrito with two units of beans and one unit each of beef, cheese and salsa. This constructor does not receive any parameters. The customer name which is associated with this burrito should be "No Name". 2) A custom constructor that will allow a custom burrito to be constructed based on parameters which specify the amount of beans, beef, cheese, salsa and the customer name. 3) A method called "print_order" which we can use to ask our burrito objects to print out their ingredients and associated customer name. 4) A method called "weight" which we can use to ask our burrito to tell us how much it weighs. (assume one ounce per unit of each of the ingredients) This method should not perform any output, but should instead simply return the weight of the burrito. You should write a main method to create two burrito objects. The first burrito will be a "default" burrito and the second one will be custom made. The input values for the custom burrito are given below in the example. These will be hard coded into your main method. The test program will also invoke the internal mechanisms within each burrito to print the ingredients and weight as shown below. Late breaking news! In response to market demand, you need to also include a way to update a burrito object after it has been created, but prior to sending it to the OOBM. Include the capability to double the ingredients of the burrito by invoking a method called "gutBuster" which will be part of the burrito object. In your testing, create an initial (default) burrito, ask the burrito object to print its contents, and its weight, then Super Size the burrito via the gutBuster method and then again ask the burrito to print its contents and weight. Then repeat the same six steps (create, print, weigh, gutBuster, print, weigh) for a custom burrito which matches the ingredients list that is shown below. Notes: 1) Protect the data in this object from modification (except for via the mechanisms you provide). 2) If you're wondering which block of code should generate the output(s), examine the sample piece of code below and the sample output it generates. That will show where the output is not coming from! Also, the constructor produces no output. Here is a sample piece of code which you will integrate into your main method: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create a custom burrito! Burrito b1 = new Burrito(8,2,3,1,"Big Al"); b1.print_order(); System.out.println("The burrito weighs " + b1.weight() + " ounces."); b1.gutBuster(); b1.print_order(); System.out.println("The burrito weighs " + b1.weight() + " ounces."); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When run, it produces the following output: (your program output should be very similar) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Big Al's burrito will be made of: 8 ounce(s) of beans 2 ounce(s) of beef 3 ounce(s) of cheese 1 ounce(s) of salsa The burrito weighs 14 ounces. Invoking the Gut Buster Special!!! Big Al's burrito will be made of: 16 ounce(s) of beans 4 ounce(s) of beef 6 ounce(s) of cheese 2 ounce(s) of salsa The burrito weighs 28 ounces. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started