Problem #13
Given a method parameters circ of type Circle and elli of type Ellipse
Send any message to circ and assign the return value to elli
Return elli
We could take this approach:
Given:
elli = circ.SOMEMESSAGE()
📋
We know elli is of type Ellipse.
We now look at the available messages for SOMEMESSAGE.
We know that SOMEMESSAGE must be a method on Circle (because circ is type Circle).
Here are the candidates (from Headers page):
public Frame getBoundary()
public Point getAnchor()
public int getLongDimension()
public void drawOn(Graphics g, Color color)
public void moveBy(Point v)
public void setAnchor(Point anchorPoint)
public void setLongDimension(int longDimension)
None of these messages return type Ellipse.
Therefore, this statement is impossible:
elli = circ.SOMEMESSAGE()
📋
That is, there is no real message we can replace the template "SOMEMESSAGE" with. Therefore, we have no solution.
Introduction To Objects With Java (Chapter 405 - Method Headers)
Chapter 405 - Method Headers
Example Problem #13 Details
Contents
Definition
Headers
Example Problems
Example
Challenge Problems
Challenge
Chapter
Top
Search
TOC