Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class sitapp publie atatie void main(String[] arga) Canastructioniteell Constructioni tesnew constructionite(5: Canatruction Items (0) Cement(s); ConstructionItems [1]-ce Stones (3) Canatruction Items (2) Sand (4)
public class sitapp publie atatie void main(String[] arga) Canastructioniteell Constructioni tesnew constructionite(5: Canatruction Items (0) Cement(s); ConstructionItems [1]-ce Stones (3) Canatruction Items (2) Sand (4) ConstructionItems (3) - Cement (4) ConstructionItems (4) Sand (4) Mysite site=new Mysite ConstructionItena); site.coatCaleulation () interface Constructable 1 // fill the code Abstract class ConstructionItem private double amount Incubes publie double getAnunt Incuba () // fill the code 1 the code elesa Cement extends ConstructionItem 1 // till the code elesa Sand extends Construction Item // till the code 1 elesa Stonea extends Constructioniten // Ell the code elesa Mysite Implementa Constructable ConstructionItemIl Construction tema; Roverride public void coat calculation) // fill the code // overload the constructor to pass the array of constructionItems Sample output of the program is as follows Cement=> 1000.0 * 5.0=5000.0 Stone=> 750.0 3.0=2250.0 Sand=> 850.0 * 4.0=3400.0 Cement=> 1000.0 * 4.0=4000.0 Sand=> 850.0 4.0=3400.0 The total cost is = 18050.0 -End of Paper Assume that you are the associate software engineer of "Sharp Matic company, and you are asked to implement a java program based on the Object-Oriented Programming (OOP) concepts. This system is for a building construction side and you are going to add deferent ConstructionItems (Cement, Sand, Stones) for the Site in deferent quantities of cubic meters. Quantities are passed through the constructor. You can refer the output is given in SiteApp class and adjust your code accordingly First implement the Constructable interface and declare void costCalculation() method. Then implement the ConstructionItem abstract class and declare the methods with retum types showItem():String, getCost(): double, getQuantity():double Create concrete classes called Cement. Sand and Stones and override all abstract methods showItem(), getCost() and getQuantity(). Assume that Cement cost Rs. 1000.00 per cubic meter, Sand cost Rs. 850.00 per cubic meter and Stone cost Rs.750.00 per cubic meter. Add a private property called amountinCubes (set the datatype as double) to ConstructionItem class with a getter and overload the constructor of each sub-class (Cement, Sand and Stones). Similarly create a class called MySite and implement the Constructable interface with in the class and override the costCalculation() method. Then overload the constructor to pass the array of ConstructionItems (E.g. - ConstructionItem [ D. The MySite class should calculate the cost in each ConstructionItem, and it should print the sub total of each order line and at the end it should print the total cost. When calculate the line total it should multiply each ConstructionItem's cost with the given quantity and use iteration to print ConstructionItem name, cost, quantity and the line total as per the console output
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