Question: Learning Outcome: Demonstrate class association (has-a relationships) Use existing code as part of your program code reading StdDraw.java In this lab we create 4 classes:

Learning Outcome:

Demonstrate class association (has-a relationships)

Use existing code as part of your program

code reading

StdDraw.java

In this lab we create 4 classes: Point, Line, LineDrawing, and LineDrawingApp, which is a test client for the other three classes. This lab demonstrates class association, which models the has-a relationship between classes. A LineDrawing has many lines, a line has 2 points (start point, end point) The classes should be implemented based on the UML class diagrams and the description below. The three draw methods should be implemented by using class StdDraw.

Learning Outcome: Demonstrate class association (has-a relationships) Use existing code as part

Class Point has an x an y coordinate of type double, a parameterized constructor, getters (no setters) and a method calld draw that uses a method from class StdDraw to draw the point (we just allowed x any between 0 and 1)

Class Line,has 2 fields of type Point: start and end It also has a parameterized ctor and a method draw that can draw the line (use a method from class StDraw to draw the line)

Class LineDrawing,has two static method: drawTriangle and drawHouse. Neither of the methods has a paraemter. The triangle and the house are hard coded in the method implementation. Class LineDrawingApp tests both methods of class LineDrawing by calling them. Keep in mind that the methods are static. Static methods should be called on the type.

Point - x double - y double + Point (x double, y double) +getX ) double +getY (): double + draw () Line -from Point - to Point Line (from:Point, to + draw () Point) LineDrawing lines ArrayListcLine> +LineDrawgin (lines ArrayList ) + draw ()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!