Given the following template of abstract superclass named Mobile Phone and subclasses named IPhone and Android:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given the following template of abstract superclass named Mobile Phone and subclasses named IPhone and Android: public abstract class Mobile Phone protected String serialNo; //serial number protected int capacity; //phone storage: //32, 64, 128, 256 or 512 protected int batteryLasting; protected String color; protected String datePurchased; //Methods: //constructors, accessor, printer //eg 4000mAH //phone color //format dd/mm/yyyy public abstract double calPrice(); } public class IPhone extends Mobile Phone I private String type; private String category; //iphonell, iphone12 or iphone13 //standard, pro or pro max private boolean insurance; //true if taken the insurance //otherwise, false } //Methods: //constructors, accessor, printer public double calPrice () () //calculate total price public class Android extends Mobile Phone private String brand; private boolean dualSim; //Methods: //Asus, Lenovo or Redmi //true if dual sim card //otherwise, false //constructors, accessor, printer public double calPrice() {_.) //calculate total price } a) Write the following method definition: i) Accessor methods that return every attribute in superclass. a) Write the following method definition: i) Accessor methods that return every attribute in superclass. (5 marks) ii) Processor method named calPrice () for both subclasses that calculate and return the total price of the phone that need to be paid by the buyer, based on the following information: b) Write code fragments in the application/ driver class that can perform the following tasks: (Assume all relevant methods have been defined in all classes involved) i) Declare an array of an object named phone to store various types of mobile Phone. (Can be any size of array) (1 mark) ii) Calculate and display the total price for every type of iPhone bought without insurance. (8 marks) iii) Count the number of all Asus mobile phones that were bought in December and display the related information about each object using the printer method. (6 marks) Given the following template of abstract superclass named Mobile Phone and subclasses named IPhone and Android: public abstract class Mobile Phone protected String serialNo; //serial number protected int capacity; //phone storage: //32, 64, 128, 256 or 512 protected int batteryLasting; protected String color; protected String datePurchased; //Methods: //constructors, accessor, printer //eg 4000mAH //phone color //format dd/mm/yyyy public abstract double calPrice(); } public class IPhone extends Mobile Phone I private String type; private String category; //iphonell, iphone12 or iphone13 //standard, pro or pro max private boolean insurance; //true if taken the insurance //otherwise, false } //Methods: //constructors, accessor, printer public double calPrice () () //calculate total price public class Android extends Mobile Phone private String brand; private boolean dualSim; //Methods: //Asus, Lenovo or Redmi //true if dual sim card //otherwise, false //constructors, accessor, printer public double calPrice() {_.) //calculate total price } a) Write the following method definition: i) Accessor methods that return every attribute in superclass. a) Write the following method definition: i) Accessor methods that return every attribute in superclass. (5 marks) ii) Processor method named calPrice () for both subclasses that calculate and return the total price of the phone that need to be paid by the buyer, based on the following information: b) Write code fragments in the application/ driver class that can perform the following tasks: (Assume all relevant methods have been defined in all classes involved) i) Declare an array of an object named phone to store various types of mobile Phone. (Can be any size of array) (1 mark) ii) Calculate and display the total price for every type of iPhone bought without insurance. (8 marks) iii) Count the number of all Asus mobile phones that were bought in December and display the related information about each object using the printer method. (6 marks)
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
What is the output produced from the following statements? System.out.println("name\tage\theight"); System.out.println("Archie\t17\t5'9\""); System.out.println("Betty\t17\t5'6\"");...
-
The assessed value on a property increased from $285,000 last year to $298,000 in the current year. Last years property tax rate was $1.56324 per $100 of assessed value. a. What will be the change in...
-
Owen has his home and its contents insured under a Homeowners 3 (special form) policy. He carries $160,000 of insurance on the home, which has a replacement cost of $200,000. Explain the extent to...
-
Using an Internet search engine, find information about the fourth industrial revolution. What are the characteristics of an industrial revolution? What were the first three industrial revolutions,...
-
The post-closing trial balance of Violet Corporation at December 31, 2012, contains the following stockholders equity accounts. Preferred Stock (15,000 shares issued)........... $ 750,000 Common...
-
Your company has a Microsoft 365 subscription. You need to create user accounts for 1,000 new employees by uploading a list of users to Microsoft 365. What type of file should you use from the...
-
1.Which of the following statements about the statement of cashflows is not correct? It does not replace the income statement. It provides details as to how cash changed during a period. It provides...
-
The simple interest on an investment is directly proportional to the amount of the investment. By investing $ 4 2 5 0 in a certain bond issue, you obtained payment of $ 2 3 3 . 7 5 after 1 year. Find...
-
Elmo Security Consultants ( ESC ) offer a standardized review of data security for small business owners. The following data apply to the provision of these reviews: Sales price per unit ( 1 unit = 1...
-
A company that uses job order costing purchases $ 5 8 , 0 0 0 in raw materials for cash. It then uses $ 1 9 , 0 0 0 of raw materials as indirect materials and uses $ 3 0 , 6 0 0 of raw materials as...
-
Ring Panda, a fashion jewellery distributor, issues dividends semi-annually. The most recent dividend was $1.5, dividends are expected to grow at 8% p.a, compounded semi-annually, and the cost of...
-
On January 1 , 2 0 2 2 , Blossom Corporation had the following stockholders equity accounts. Common Stock ( no par value, 9 3 , 0 0 0 shares issued and outstanding ) $ 1 , 4 4 0 , 0 0 0 Retained...
-
Explain the effects of health insurance on the demand and supply of health care services, access, and cost.
-
Question 6.10 Current and deferred tax worksheets and tax entries From the hip Ltd?s statement of profit or loss for the year ended 30 June 2007 and extracts from its statements of financial position...
-
LDDS suffered from high fixed costs coupled with a lack of technical knowledge and expertise in optimizing the configuration of circuits, which resulted in high line costs. True/False
-
If the notes to the financial statements indicate that a company is capitalizing costs that other companies in the same industry recognize as expenses, it is a signal that the company is capitalizing...
-
WorldCom prepared its financial statements to meet the expectations of securities analysts despite needing to report actual earnings and accurate financial results. True/False
Study smarter with the SolutionInn App