I'm having trouble understanding the diagram and the specifications below.
How do I make the double getCalculaFrete()
method return the same value returned by the double calcularFretePedido()
method, being called by the calculaFrete
variable in the Pedido
class, that is, calculaFrete.calcularFretePedido()
.
And each concrete class that inherits from the abstract class CalcularFrete
should return a double
value relative to the value of its freight. An example would be, a standard freight costs $ 3.50 and an express freight costs $ 5.50.
Create two objects to test this program in the Main class. In order for the test to be done correctly, the objects must be of the type of the Order class and to show the freight value of each one, it is enough to access the double getCalculatureFrete () method of that same object, that is, considering that an object was created with the following name → Request request1 ..., to show the value of your freight simply trigger the return of such form → request1.getCalculateFrete () and print it. Thanks to polymorphism, the Request class constructor receives any object of a given class that has a "is one" relationship to the abstract class.
I'm having trouble printing it too ... Help ...
Thank you!