Lab 09

Bunch of Lines

 

Objective:

 

Write a bunch of classes that will draw a bunch of lines!  Don’t worry you don’t have to write any graphics, as that part is provided in the driver.  Each line is drawn based on a math function that takes in a given x coordinate and will return its y coordinate.

 

Lab Solution

 

 

HINT: If the lines look weird it may be a good idea to print out each of the coordinates and observing what is going on in the method getYPoint.

 

Example Dialog:

Lab Report Questions

  1. Draw a UML class diagram for this project
  2. Describe polymorphism

Solution Tests:

  1. Is your name written as a comment in all source files?
  2. Does the solution compile (no syntax errors)?

3.      Does your output match the example GUI?

 

Lab Report

  1. Create a section named “Problem” and describe this lab’s problem in your own words. (10pts).
  2. Create a section named “Solution Description” and describe how the code solves the problem in your own words. (10pts).
  3. Create a section named “Problems Encountered” and describe the various syntax, run-time, and logic errors that were encountered while implementing the solution. (10pts).
  4. Describe polymorphism in OOP. (10pts).
  5. Briefly describe the similarities between classes and interfaces in Java. (10pts).
  6. Briefly describe the differences between classes and interfaces in Java. (10pts).
  7. If we consider Classes to be “blueprints” for Objects, then what is the relationship between Interfaces and Classes? Interfaces and Objects? (10pts).
  8. Is it possible to construct instances of an Interface in Java? (10pts).
  9. What reserved word is used to establish a polymorphic relationship between a class and an interface in Java? (10pts).
  10. What reserved word is used to establish inheritance (“is a”) relationship between two interfaces in Java? (10pts).

 

Finally: