Fix codeline in JAVA
Budget: $10 – $30 USD
Can someone please explain to me how to do this?:
The getInfo() method in the Product class can display the final product price of both types. That is the getInfo() method (immediately in the Product class) can call the countPrice() method to print the total price.
The getInfo() method in the successor classes of the Product class can call its parent version (with 1 additional piece of information each - Weight or Volume) using super.getInfo().
Then, in the main class you don't have to call the countPrice() method for each product, but only getInfo().
public class Main {
public static void main (String[] args) {
Chocolate chocolate = new Chocolate("Nestle", 100,253596,100);
System.out.println(chocolate.getInfo());
System.out.println("Total Price: " + chocolate.countPrice());
Wine wine = new Wine("Merlot",100,578551,750);
System.out.println(wine.getInfo());
System.out.println("Total Price: " + wine.countPrice());
}
}
The getInfo() method in the Product class can display the final product price of both types. That is the getInfo() method (immediately in the Product class) can call the countPrice() method to print the total price.
The getInfo() method in the successor classes of the Product class can call its parent version (with 1 additional piece of information each - Weight or Volume) using super.getInfo().
Then, in the main class you don't have to call the countPrice() method for each product, but only getInfo().
public class Main {
public static void main (String[] args) {
Chocolate chocolate = new Chocolate("Nestle", 100,253596,100);
System.out.println(chocolate.getInfo());
System.out.println("Total Price: " + chocolate.countPrice());
Wine wine = new Wine("Merlot",100,578551,750);
System.out.println(wine.getInfo());
System.out.println("Total Price: " + wine.countPrice());
}
}
Related categories:
PHP
C Programming
Business, Accounting, Human Resources & Legal
JavaScript
Software Architecture