Question: Question 1 for reference- Question 2 a) Write JAVA codes for the following conditions: 1. Declare an interface named as ArithmeticOperation, the interface consists of

 Question 1 for reference- Question 2 a) Write JAVA codes for

Question 1 for reference-

the following conditions: 1. Declare an interface named as ArithmeticOperation, the interface

consists of two methods (you may create ant relevant methods). II. Write

at least TWO (2) classes that use the interface. (6 marks) b)

Referring to Question 1, why do we need to make the data

Question 2 a) Write JAVA codes for the following conditions: 1. Declare an interface named as ArithmeticOperation, the interface consists of two methods (you may create ant relevant methods). II. Write at least TWO (2) classes that use the interface. (6 marks) b) Referring to Question 1, why do we need to make the data members as private? Also, suggest necessary amendment can be made for the accessibility of the data members in the super class. (3 marks) c) Compare between abstract class and interface. Relate with Question 1 and Question 2(a). (4 marks) d) Explain the use of super keyword. Relate with Question 1. (3 marks) Question 1 Given the following CyclingGlass and SwimmingGlass subclass are inherited from SportVisionShop superclass. Superclass : SportVisionShop Attributes: private String custorderNo private String custorderDate private double deposit Pymt // customer order number // date of order public clearVision Shop (String orderNo, orderDate, double deposit) // getter and setter methods Abstract Method: public abstract double calCharges() //method to calculate the price Subclass : Cycling Glass Attributes: private char type_glass /* 'T' - Transition Glass, 'p' - Polarized glass, 'I' - Iridium glass */ private boolean uvProtection; /* with UV protection extra RM 30 will be charge to the total price */ Method: /ecessary constructor, getter and setter methods public double calcharges() //method to calculate charges=price-deposit public String toString() // method to display the data members Details of charges are shown in Table below: Glass Type Price Transition RM 400.00 Polarized RM 450.00 Iridium RM 600.00 Subclass : SwimmingGlass Attributes: private char Type; // 'A' - Anti-fogging goggle, 'S' - short-sighted goggle private String style; // "Retro", "Warrior" or "Modern" Method: /ecessary constructor, getter and setter methods public double calCharges() //method to calculate the price public String toString() // method to display the data members Details of charges are shown in table below: Style and Discount Glass Type Price Retro Modern RM 180.00 8% 10% Anti-Fogging goggle Short-sighted goggle RM 300.00 5% 10% a) Write the constructor definition for both subclasses. (4 marks) b) Write the definition of calCharges() for both subclasses. (8 marks) c) Write a Java application which uses the concept of polymorphism to: Store data on various types glasses into an array of object. The number of data to be stored and information on each glass are given by the user. II. Determine and display the number of customers who buy cycling and swimming glass from the clearVisionShop outlet. III. Display information of all customer who have bought short-sighted goggle (Swimming Glass). (13 marks) Question 2 a) Write JAVA codes for the following conditions: 1. Declare an interface named as ArithmeticOperation, the interface consists of two methods (you may create ant relevant methods). II. Write at least TWO (2) classes that use the interface. (6 marks) b) Referring to Question 1, why do we need to make the data members as private? Also, suggest necessary amendment can be made for the accessibility of the data members in the super class. (3 marks) c) Compare between abstract class and interface. Relate with Question 1 and Question 2(a). (4 marks) d) Explain the use of super keyword. Relate with Question 1. (3 marks) Question 1 Given the following CyclingGlass and SwimmingGlass subclass are inherited from SportVisionShop superclass. Superclass : SportVisionShop Attributes: private String custorderNo private String custorderDate private double deposit Pymt // customer order number // date of order public clearVision Shop (String orderNo, orderDate, double deposit) // getter and setter methods Abstract Method: public abstract double calCharges() //method to calculate the price Subclass : Cycling Glass Attributes: private char type_glass /* 'T' - Transition Glass, 'p' - Polarized glass, 'I' - Iridium glass */ private boolean uvProtection; /* with UV protection extra RM 30 will be charge to the total price */ Method: /ecessary constructor, getter and setter methods public double calcharges() //method to calculate charges=price-deposit public String toString() // method to display the data members Details of charges are shown in Table below: Glass Type Price Transition RM 400.00 Polarized RM 450.00 Iridium RM 600.00 Subclass : SwimmingGlass Attributes: private char Type; // 'A' - Anti-fogging goggle, 'S' - short-sighted goggle private String style; // "Retro", "Warrior" or "Modern" Method: /ecessary constructor, getter and setter methods public double calCharges() //method to calculate the price public String toString() // method to display the data members Details of charges are shown in table below: Style and Discount Glass Type Price Retro Modern RM 180.00 8% 10% Anti-Fogging goggle Short-sighted goggle RM 300.00 5% 10% a) Write the constructor definition for both subclasses. (4 marks) b) Write the definition of calCharges() for both subclasses. (8 marks) c) Write a Java application which uses the concept of polymorphism to: Store data on various types glasses into an array of object. The number of data to be stored and information on each glass are given by the user. II. Determine and display the number of customers who buy cycling and swimming glass from the clearVisionShop outlet. III. Display information of all customer who have bought short-sighted goggle (Swimming Glass). (13 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!