Question

CUNY/CSI CODE LISTING 1 public Interface Calculator f public double getCurrentValue); public class Simplecalculator implement
questions based from above handout

(5 x 4:20 points) 17.Given the detail shown in the UML Class diagram, would the Java Compiler accept the following statement
CUNY/CSI CODE LISTING 1 public Interface Calculator f public double getCurrentValue); public class Simplecalculator implements Calculator ) public Class FinancialCalculator extends Simplecalculator public class ScientificCalculator extends SimpleCalculator [UML DIAGRAM) FIGURE Tredabie FinancialSecority +gell ost Trada Tme): Date Debt Asset Bond Stock ETF ComvertableBond
(5 x 4:20 points) 17.Given the detail shown in the UML Class diagram, would the Java Compiler accept the following statement as valid? Tradable t-new Bond ) For Questions 18-21, provide the Class or Interface definition Java code for each type listed below based on UML Diagram details. Remember: in order to get full credit, your code must reflect all details defined in the diagram. 18. Tradable 19. Stock 20. Bond 1.FinancialSecurity
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello, I have answered this question before. Please find your answers below and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

17. Tradable t = new Bond();

This statement is completely valid since Bond implements Tradable interface indirectly. That is Bond extends Debt which extends FinancialSecurity that implements Tradable. So according to the inheritance hierarchy, Bond is a child class of Tradable.

Java code for each of the below classes/interfaces. Assuming there are no abstract classes in the diagram.

18. Tradable

import java.util.Date;

public interface Tradable {

      public double getPrice();

      public Date getLastTradeTime();

}

19. Stock

public class Stock extends Asset {

      // no info about the additional data fields or methods

}

20. Bond

public class Bond extends Debt{

      // no info about the additional data fields or methods

}

21. FinancialSecurity

import java.util.Date;

public class FinancialSecurity implements Tradable {

      @Override

      public double getPrice() {

            // should return a double value

            return 0;

      }

      @Override

      public Date getLastTradeTime() {

            // should return a Date value, returning null for now.

            return null;

      }

}

Add a comment
Know the answer?
Add Answer to:
questions based from above handout CUNY/CSI CODE LISTING 1 public Interface Calculator f public double getCurrentValue); public class Simplecalculator implements Calculator ) public Class Finan...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT