CSC113_Tutorial6

# CSC113_Tutorial6 - King Saud University College of Computer...

This preview shows pages 1–3. Sign up to view the full content.

King Saud University College of Computer and Information Systems, Department of Computer Science CSC 113: Java Programming-II, Spring2011, March 26, 2011 Tutorial #6 : Polymorphism The problem: In a Cartesian coordinate system, we have 20 shapes. Each of these shapes can be either a circle or a rectangle. The position and size of each circle can be described be a center point and a radius value, while location and size of a rectangle is described by a center point and values for the length and width, having all rectangles’ edges in parallel either to the x-axis or the y- axis. We need to know whither a point p belongs to the area defined by one shape or more, and find those shapes. A solution: Consider the following class diagram which specifies five classes and their relationships: Implementations of classes Point and TestShape are given.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Determine abstract methods and classes then implement classes: Shape, Circle and Rectangle based on the class diagram and description below: Class
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

CSC113_Tutorial6 - King Saud University College of Computer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online