1.2 Given the Fruit class with the following data members attributes): Class name :Fruit Attributes :String name; /fruit name /local or imported String type; double weight; |/in kg double price;...


Java - OOP


1.2<br>Given the Fruit class with the following data members attributes):<br>Class name<br>:Fruit<br>Attributes<br>:String name;<br>/fruit name<br>/local or imported<br>String type;<br>double weight; |/in kg<br>double price;<br>//price per kilogram<br>Method<br>: constructor, mutator, accessor, processor, printer<br>a) Write the definition of the following methods:<br>i. Default/Normal/Copy Constructor.<br>ii. Mutator/Setter for each attribute.<br>iii. Getter/Accessor/Retriever for each attribute.<br>iv. A Processor method named isLocal () that returns true if it is local fruit<br>or returns false otherwise.<br>v. A processor method named calcTotalPrice() calculates and returns<br>the total price of the fruit. In order to encourage the buyers to buy the local<br>fruits, 3% discount is given on the total price.<br>vi. Printer method named toString() to return the objects' information.<br>b) Write an application program to do the following tasks:<br>i.<br>Declare an array of object named fruitList and store some data onto<br>array.<br>ii. Display the name of local fruits which has the highest price.<br>iii. Calculate total sale of the imported fruits.<br>

Extracted text: 1.2 Given the Fruit class with the following data members attributes): Class name :Fruit Attributes :String name; /fruit name /local or imported String type; double weight; |/in kg double price; //price per kilogram Method : constructor, mutator, accessor, processor, printer a) Write the definition of the following methods: i. Default/Normal/Copy Constructor. ii. Mutator/Setter for each attribute. iii. Getter/Accessor/Retriever for each attribute. iv. A Processor method named isLocal () that returns true if it is local fruit or returns false otherwise. v. A processor method named calcTotalPrice() calculates and returns the total price of the fruit. In order to encourage the buyers to buy the local fruits, 3% discount is given on the total price. vi. Printer method named toString() to return the objects' information. b) Write an application program to do the following tasks: i. Declare an array of object named fruitList and store some data onto array. ii. Display the name of local fruits which has the highest price. iii. Calculate total sale of the imported fruits.

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here