Professional Documents
Culture Documents
Problem Description:
Define the Circle2D class that contains:
• Two double data fields named x and y that specify the
center of the circle with get methods.
• A data field radius with a get method.
• A no-arg constructor that creates a default circle
with (0, 0) for (x, y) and 1 for radius.
• A constructor that creates a circle with the specified
x, y, and radius.
• A method getArea() that returns the area of the
circle.
• A method getPerimeter() that returns the perimeter of
the circle.
• A method contains(double x, double y) that returns
true if the specified point (x, y) is inside this
circle. See Figure 10.14(a).
• A method contains(Circle2D circle) that returns true
if the specified circle is inside this circle. See
Figure 10.14(b).
• A method overlaps(Circle2D circle) that returns true
if the specified circle overlaps with this circle. See
the figure below.
Figure
(a) A point is inside the circle. (b) A circle is
inside another circle. (c) A circle overlaps another
circle.
Design:
Draw the UML class diagram here
Circle2D
Coding: (Copy and Paste Source Code here. Format your code using Courier 10pts)
class Circle2D {
// Implement your class here
}
2
Submit the following items:
1. Print this Word file and Submit to me before the class on the due day.
2. Compile, Run, and Submit to LiveLab (you must submit the program regardless
whether it complete or incomplete, correct or incorrect)
3
Solution Code:
class Circle2D {
private double x, y;
private double radius;
public Circle2D() {
x = 0;
y = 0;
radius = 1;
}
4
return radius * radius * Math.PI;
}
5
Another random document with
no related content on Scribd:
[“God’s blessing on his heart that made this:” sayd one, “specially
for reuiuing our auncient liberties. And I pray God it may take such
place with the magistrates, that they may ratifie our olde freedome.”
“Amen,” sayd another: “for that shall bee a meane both to stay and
vpholde themselues from falling, and also to preserue many kinde,
true, zealous, and well meaning mindes from slaughter and infamy. If
king Richarde and his counsailours had allowed, or at the least but
winked at some such wits, what great commodities might they haue
taken thereby? First, they should haue knowen what the people
misliked and grudged at, (which no one of their flatterers either
woulde or durst haue tolde them) and so mought haue found meane,
eyther by amendment (which is best) or by some other pollicy to
haue stayed the people’s grudge: the forerunner commonly of ruler’s
destruction.[1750] Vox populi, vox Dei, in this case is not so famous a
prouerbe, as true: the experience of all times doe[1751] approue it.
They should also haue bene warned of their owne sinnes, which call
continually for God’s vengeaunce, which neuer faileth to fall on their
neckes sodainly and horribly, vnles it bee stayed with hearty
repentaunce. These weighty commodities mought they haue taken
by Collingbourn’s vaine rime. But, as all thinges worke to the best in
them that bee good, so best thinges heape vp mischiefe in the
wicked, and all to hasten their vtter destruction. For after this poore
wretche’s lamentable persecution (the common rewarde of best
endeuours) strait followed the fatall[1752] destruction both of this
tyrant, and of his tormentours. Which I wishe might bee so set forth,
that they might bee a warning for euer, to all in authority, to beware
howe they vsurpe or abuse theyr offices.” “I haue here,” quoth[1753] I,
“king Richard’s tragedy.” “Reade it, wee pray you:” quoth[1754] they.
“With a good will,” quoth[1755] I. “For the better vnderstanding
whereof, imagine that you see him tormented with Diues in the
deepe pit of hell, and thence howling this which followeth.”]
[How Richarde Plantagenet Duke of
Glocester murdered his brother’s
children, vsurping the crowne, and in
the third yeare of his raigne was most
worthely depriued of life and
kingdome, in Bosworth plaine, by
Henry Earle of Richmond after called
King Henry the vij. the 22 of August
1485.[1756]
1.
2.
3.
4.
5.
6.
7.
8.
9.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
Betyde mee lyfe or death I desperatly ran,
And ioyned mee in battayle with this earle so stoute,
But fortune so him fauoured that hee the battayle wan,
With force and great power I was beset about:
Which when I did beholde, in midst of the whole route,
With dint of sword I cast mee on him to be reuenged,
Where in the midst of them my wretched life I ended.
41.
42.
Loe, heare you may behold the due and iust rewarde
Of tyranny and treason, which God doth most detest:
For if vnto my duety I had taken regarde,
I might haue liued still in honour with the best,
And had I not attempt the thing that I ought leste:
But desyre to rule, alas, did mee so blinde,
Which caused mee to doe agaynst nature and kynde.
43.
F. Seg.[1778]]
[When I had read this, we had much talke about it. For it was
thought not vehement enough for so violent a man as king Richard
had bene. The matter was well enough liked of some, but the meetre
was misliked almost of all. And when diuers therefore would not
allowe it, “What,” quoth[1779] one, “you know not wherevpon you
sticke: els you would not so much mislike this because of the
vncertaine meeter. The cumlines called by the rhetoricians decorum,
is specially to bee obserued in all thinges. Seing than that king
Richard neuer kept measure in any of his doings, seeing also hee
speaketh in hell, whereas is no order: it were against that[1780]
decorum of his personage, to vse either good meetre or order. And
therefore if his oration were farre worse, in my opinion it were more
fit for him. Mars and the muses did neuer agree. Neither is to be
suffered, that their milde sacred arte should seeme to proceede from
so cruell and prophane a mouth as his: seeing they themselues doe
vtterly abhorre it. And although wee read of Nero, that hee was
excellent both in musicke and in versifying, yet doe not I remember
that euer I sawe any song or verse of his making: Minerua iustly
prouiding, that no monument should remayne of any such vniust
vsurpation. And therefore let this passe euen as it is, which the writer
I know both could and would amend in many places, saue for
keeping the decorum, which he purposely hath obserued herein.” “In
deede,” quoth[1781] I, “as you say: it is not meete that so disorderly
and vnnaturall a man as king Richard was, should obserue any
metricall order in his talke: which notwithstanding in many places of
his oration is very well kepte: it shall passe therefore euen as it is,
though too good for so euill[1782] a person.”[1783] Then they willed
mee to reade the blacke Smith. “With a good will,” quoth I: “but first
you must imagin that you see him standing on a ladder ouer shrined
with the Tyburne, a meete stage for all such rebelles and traytours:
and there stoutly saying as followeth.”]
The wilfvll fall of the blacke Smith,
and the foolishe ende of the Lorde
Awdeley, in Iune, Anno 1496.[1784]
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Such is the courage of the noble hart,
Which doth despise the vile and baser sort,
Hee may not touch that sauers of the cart,
Him listeth not with ech jacke lout to sport,
Hee lets him passe for payring of his porte:
The iolly egles catch not litle flees,
The courtly silkes match seelde with homely frees.
12.
13.
14.
16.
17.
18.