Twitter Page 1: 1 2 Question 2 (35 points) public class Plan Demo 3 { {...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Twitter Page 1: 1 2 Question 2 (35 points) public class Plan Demo 3 { { public static void main(String[] args) CommercialPlan cp = new CommercialPlan(12345, "5001 Java blvd, San Diego, CA 92111", "Engineering", 350 0.5); = new Residential Plan (10035, "222 Java In, San Diego, CA 92000", 2, 2400.0); -- -- -- 4 5 ResidentialPlan rp rp.setNumberOfStories(4); System.out.println(cp); System.out.println(); System.out.println(rp); } } public class CommercialPlan { private int parcelNumber; private String address; private String business Type; Favor { private double area; public String approval Process() String result; if(area <3000) result = " \t1-Get permit from the city commercial unit"; else result = " \t1-Get permit from the city commercial unit \t2-Get approval from business office"; return result; public String toString() } } { public class ResidentialPlan tes AirDi Rece Appli Dow Red Page 1: 1 2 3 -- -- 4 5 -- - C (10 Points): Create a new class called Plan Demo2.java and in its main method implement the following: 1. Create two reference variables of type Plan called planCP and planRP. 2. Assign planCP to an instance of the new CommercialPlan class that you created in part B and assign planRP to an instance of the new ResidentialPlan class that you also created in part B. 3. Print both planCP and planRP variables and specify whether the toString() method of the Plan class is called or the toString() methods of the planCP and plan RP classes are called. a. Explain why the above has happened. b. In Object Oriented paradigm, what is this phenomenon called? 4. Call planRP. getNumberOfStories() in PlanDemo2.java. a. What is the result? Explain why it is happening. b. If there is an issue, just explain how it can be fixed (writing code to fix the issue is not necessary). 5. Submit Plan.java, CommercialPlan.java, ResidentialPlan.java, PlanDemo.java and PlanDemo2.java files in a zip file. hot 09 AM hot 27 AM hot 36 AM hot 37 PM Yello Paragraph BI U A/ Oran IIII O + hot 46 PM hot .01 PM Page 1: 1 1 2 1 1 4 5 1 3 H public class Residential Plan { private int parcelNumber; private String address; private int numberOfStories; private double area; public String approvalProcess() { return " \t1-Get permit from the city residential unit"; } public String toString() } In the above code, the Plan Demo class creates instances of Commercial Plan and Residential Plan classes, calls the setNumberOfStories method of the Residential Plan class instance and prints both instances. Your task is to complete the above classes as follows: A - (10 Points): 1. Copy the above classes into their corresponding java files in an IDE of your choice. 2. Complete Commercial Plan and Residential Plan classes by adding: a. Constructors i. Commercial Plan order of parameters: 1. (parcelNumber, String address, String business Type, double area) ii. Residential Plan order of parameters: 1. (parcelNumber, String address, int numberOfStories, double area) b. Setter and getter methods for all their instance variables c. Complete the toString method of each class 2. Run PlanDemo.java and verify that its output is shown without any errors. Although, PlanDemo.java runs fine, however, Commercial Plan and ResidentialPlan classes have a lot of duplicate code. B - (15 Points): Use Inheritance to reduce code duplication, as follows: 1. Create a class called Plan.java. This class will contain the code that is in common between Page 1: 1 2 4 5 1 3 B - (15 Points): Use Inheritance to reduce code duplication, as follows: 1. Create a class called Plan.java. This class will contain the code that is in common between Commercial Plan and ResidentialPlan classes. 2. Add a constructor method to the Plan class, which receives values for all instance variables of the Plan class as parameters. (Note: Do Not add a default constructor to the Plan class) 3. Add a toString() method to the Plan class, which prints all the instance variables of the class. 4. Modify Commercial Plan and Residential Plan classes to create new classes that inherit and use the common code from the Plan.java rather than duplicating them. 5. The approval Process () method, is a good candidate to be implemented as an abstract method. a. Explain why this method should be implemented as an abstract method. b. Implement this method as an abstract method. 6. Run the PlanDemo.java to verify that it runs correctly with your new classes. Specifically, make sure the toString() methods of the new Commercial Plan and Residential Plan classes are working correctly. Note: You should not change the PlanDemo.java class to answer part B. C- (10 Points): Create a new class called PlanDemo2.java and in its main method implement the following: 1. Create two reference variables of type Plan called planCP and plan RP. 2. Assign planCP to an instance of the new Commercial Plan class that you created in part B and assign planRP to an instance of the new ResidentialPlan class that you also created in part B. 3. Print both planCP and planRP variables and specify whether the toString() method of the Plan class is called or the toString() methods of the planCP and planRP classes are Twitter Page 1: 1 2 Question 2 (35 points) public class Plan Demo 3 { { public static void main(String[] args) CommercialPlan cp = new CommercialPlan(12345, "5001 Java blvd, San Diego, CA 92111", "Engineering", 350 0.5); = new Residential Plan (10035, "222 Java In, San Diego, CA 92000", 2, 2400.0); -- -- -- 4 5 ResidentialPlan rp rp.setNumberOfStories(4); System.out.println(cp); System.out.println(); System.out.println(rp); } } public class CommercialPlan { private int parcelNumber; private String address; private String business Type; Favor { private double area; public String approval Process() String result; if(area <3000) result = " \t1-Get permit from the city commercial unit"; else result = " \t1-Get permit from the city commercial unit \t2-Get approval from business office"; return result; public String toString() } } { public class ResidentialPlan tes AirDi Rece Appli Dow Red Page 1: 1 2 3 -- -- 4 5 -- - C (10 Points): Create a new class called Plan Demo2.java and in its main method implement the following: 1. Create two reference variables of type Plan called planCP and planRP. 2. Assign planCP to an instance of the new CommercialPlan class that you created in part B and assign planRP to an instance of the new ResidentialPlan class that you also created in part B. 3. Print both planCP and planRP variables and specify whether the toString() method of the Plan class is called or the toString() methods of the planCP and plan RP classes are called. a. Explain why the above has happened. b. In Object Oriented paradigm, what is this phenomenon called? 4. Call planRP. getNumberOfStories() in PlanDemo2.java. a. What is the result? Explain why it is happening. b. If there is an issue, just explain how it can be fixed (writing code to fix the issue is not necessary). 5. Submit Plan.java, CommercialPlan.java, ResidentialPlan.java, PlanDemo.java and PlanDemo2.java files in a zip file. hot 09 AM hot 27 AM hot 36 AM hot 37 PM Yello Paragraph BI U A/ Oran IIII O + hot 46 PM hot .01 PM Page 1: 1 1 2 1 1 4 5 1 3 H public class Residential Plan { private int parcelNumber; private String address; private int numberOfStories; private double area; public String approvalProcess() { return " \t1-Get permit from the city residential unit"; } public String toString() } In the above code, the Plan Demo class creates instances of Commercial Plan and Residential Plan classes, calls the setNumberOfStories method of the Residential Plan class instance and prints both instances. Your task is to complete the above classes as follows: A - (10 Points): 1. Copy the above classes into their corresponding java files in an IDE of your choice. 2. Complete Commercial Plan and Residential Plan classes by adding: a. Constructors i. Commercial Plan order of parameters: 1. (parcelNumber, String address, String business Type, double area) ii. Residential Plan order of parameters: 1. (parcelNumber, String address, int numberOfStories, double area) b. Setter and getter methods for all their instance variables c. Complete the toString method of each class 2. Run PlanDemo.java and verify that its output is shown without any errors. Although, PlanDemo.java runs fine, however, Commercial Plan and ResidentialPlan classes have a lot of duplicate code. B - (15 Points): Use Inheritance to reduce code duplication, as follows: 1. Create a class called Plan.java. This class will contain the code that is in common between Page 1: 1 2 4 5 1 3 B - (15 Points): Use Inheritance to reduce code duplication, as follows: 1. Create a class called Plan.java. This class will contain the code that is in common between Commercial Plan and ResidentialPlan classes. 2. Add a constructor method to the Plan class, which receives values for all instance variables of the Plan class as parameters. (Note: Do Not add a default constructor to the Plan class) 3. Add a toString() method to the Plan class, which prints all the instance variables of the class. 4. Modify Commercial Plan and Residential Plan classes to create new classes that inherit and use the common code from the Plan.java rather than duplicating them. 5. The approval Process () method, is a good candidate to be implemented as an abstract method. a. Explain why this method should be implemented as an abstract method. b. Implement this method as an abstract method. 6. Run the PlanDemo.java to verify that it runs correctly with your new classes. Specifically, make sure the toString() methods of the new Commercial Plan and Residential Plan classes are working correctly. Note: You should not change the PlanDemo.java class to answer part B. C- (10 Points): Create a new class called PlanDemo2.java and in its main method implement the following: 1. Create two reference variables of type Plan called planCP and plan RP. 2. Assign planCP to an instance of the new Commercial Plan class that you created in part B and assign planRP to an instance of the new ResidentialPlan class that you also created in part B. 3. Print both planCP and planRP variables and specify whether the toString() method of the Plan class is called or the toString() methods of the planCP and planRP classes are
Expert Answer:
Answer rating: 100% (QA)
PlanDemojava There are syntax errors and missing parts in the code provided For example there are missing semicolons incorrect method names and missing import statements You need to fix these errors b... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Data set Theory Assume an informational record with one association parent including matches (a, b) where a can't try not to be a parent of b. (a) Write a Datalog demand which gives the graph of...
-
Find the volumes of the solids generated by revolving the regions bounded by the lines and curves about the x-axis. The region between the curve and the x-axis from x = 1/4 to x = 4 y = 1/(2x)
-
Under what circumstances will a partner who is leaving a partnership give the remaining partners a bonus?
-
Mikaela's Consulting, a smaller business that advises other small businesses about marketing and online marketing, had net sales of $500,000 last year. After deducting cost of goods sold, operating...
-
What happens to the air density, pressure, temperature, and total energy when it passes through a normal shock wave?
-
If Rohr could have monitored his condition and regimen through a cell phone or other portable Internet connection, would the result in this case likely have been affected? Explain. Diabetes is a...
-
Find the net-present-value analysis of the school board's two main alternatives: (a) continue to use the full-size buses on regular routes or (b) purchase the minibuses. Should the minibuses be...
-
Two firms have the same earnings before interest and taxes of $400,000 and both have a tax rate of 40%. Firm A has $10,000 interest expense whereas firm B has no interest expense. The two firms'...
-
Think back to the CLC project in weeks 3 and 4 (and the Covid-19 issues). If you consider virtual teams, do you think that even with the increased technology of today, compared to 20 years ago or...
-
HAR Describe the transformations in the appropriate order that need to be applied HAHARS HAR to f(z) to get 9(2) ARSHAHARSHAHARSHAHARSHAHARSHAHARS g(x)=41(2x+2)-3RSHAHARSHAHARSHAHARSHAHARS...
-
Describing the level of engagement of the sales team in the company: There are 35 people that make up the sales team at XYZ Company and are generally happy with their employment. While they love...
-
Describe a recent organizational change in your organization (Google) that affected you. Extensively explain how would you discuss the leadership models , if there was no apparent leader in the...
-
One of your nurses was involved in a car accident. The nurse has recovered and wants to return to work. The nurse informs you that because of the accident they are not able to lift more than 20...
-
To counter terrorism, a new portable explosive detection system is developed. (a) Suppose that the system will be installed in an airport where only 1 out of one million baggage may contain...
-
The Pletcher Transportation Company uses a responsibility reporting system to measure the performance of its three investment centers: Planes, Taxis, and Limos. Segment performance is measured using...
-
What problem do we encounter when we try to construct an array of type E? How do we resolve this problem?
-
Write code to declare an ArrayList holding the first 10 multiples of 2: 0, 2, 4,..., 18. Use a loop to fill the list with the proper elements.
-
Write a reverse Hangman game in which the user thinks of a word and the computer tries to guess the letters in that word. The user tells the computer how many letters the word contains.
-
Analyze the last poor decision made by a group of which you were a member. What do you think contributed to the groups poor decision? Did the group think of alternative possibilities? Did the group...
-
Explain why teams and groups are not the same.
-
Discuss the various task groups within an organization and their purposes.
Study smarter with the SolutionInn App