3. (35 pts) Suppose you have an interface representing things that can be drawn on the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
3. (35 pts) Suppose you have an interface representing things that can be drawn on the screen in a drawing application: public interface Shape { } double getArea(); String getLabel (); void draw(); There may be many classes that implement the interface, such as Circle or Square, which are available to you as examples, along with the shape interface. Note that Circle has the constructor: public Circle (double x, double y, double radius, String givenLabel) // x, y is the center and square has the constructor public Square (double x, double y, double size, String givenLabel) // size is the length of each side Your task is to define a class Picture that keeps track of a list of shapes. It should have a no- argument constructor and the four methods: Methods and descriptions of class Shape void addShape (Shape s) adds the given shape to the picture, but throws an IllegalArgumentException if the shape has zero area double findTotalArea () returns the total area of all shapes added to the picture void undo () removes the most recently added shape ArrayList getLabels () returns a list of string containing the labels for all shapes in the picture Complete the class Picture below. import java.util.ArrayList; public class Picture { // TODO: add a no-argument constructor and the four methods here 3. (35 pts) Suppose you have an interface representing things that can be drawn on the screen in a drawing application: public interface Shape { } double getArea(); String getLabel (); void draw(); There may be many classes that implement the interface, such as Circle or Square, which are available to you as examples, along with the shape interface. Note that Circle has the constructor: public Circle (double x, double y, double radius, String givenLabel) // x, y is the center and square has the constructor public Square (double x, double y, double size, String givenLabel) // size is the length of each side Your task is to define a class Picture that keeps track of a list of shapes. It should have a no- argument constructor and the four methods: Methods and descriptions of class Shape void addShape (Shape s) adds the given shape to the picture, but throws an IllegalArgumentException if the shape has zero area double findTotalArea () returns the total area of all shapes added to the picture void undo () removes the most recently added shape ArrayList getLabels () returns a list of string containing the labels for all shapes in the picture Complete the class Picture below. import java.util.ArrayList; public class Picture { // TODO: add a no-argument constructor and the four methods here
Expert Answer:
Related Book For
Understanding Financial Accounting
ISBN: 978-1118849385
1st Canadian Edition
Authors: Christopher Burnley, Robert Hoskin, Maureen Fizzell, Donald
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
The new line character is utilized solely as the last person in each message. On association with the server, a client can possibly (I) question the situation with a client by sending the client's...
-
East Corp is a mature company and expects its sales and operating costs to be fixed (or unchanged) in perpetuity. It has sales of $524,000 and operating costs of $272,480. The firm has a tax rate of...
-
Show that the function is continuous on its domain. State the domain. h(x) = xesin x
-
Consider a derivative (1) of salvianolic acid B, an antioxidant and free radical scavenging compound from the root of Salvia miltiorrhiza Bunge, shown below. Answer parts i.- vii. on that molecule or...
-
As shown in Fig. 2.26. Fig. P7.41, a rectangular barge floats in a stable configuration provided the distance between the center of gravity, \(C G\), of the object (boat and load) and the center of...
-
The Hirsch Company buys inventory for $20,000 on terms of 2/10, n/30. It pays within the discount period. Required Prepare the journal entries to record the purchase and the payment under both the...
-
Refer to the Christopher Doner case at: https://www.policefoundation.org/wp-content/uploads/2015/07/Police-Under-Attack.pdf to answer each of the following questions. 1. Discuss at least three things...
-
An elevator slows to a stop, Which method below would not be a correct way to calculate the tension force that the cable exerts on the elevator? Find the work that the rope tension force exerts on...
-
a. For each transaction listed below, state whether the transaction would increase (I), decrease (D), or have no effect (NE) on Jasmine Corporation's total assets, total liabilities, and total...
-
An investor is faced with a market portfolio with an expected return of 15%, a risk free rate of 5%, and a standard deviation of market returns of 20%. a) What combination of the market portfolio and...
-
You have been asked to evaluate an infinitely lived project. Sales in the first year are projected to be $100. Costs are projected at $50. There is no depreciation, and the tax rate is 30%. The real...
-
find the correct Market Implied cost of capital (ROE) in excel using the solver function with the data given below Stock Valuation: 10-Period Growth Model 3.21% Long run dividend growth rate 12.33%...
-
Compromised need is part of Robert Taylor s definition of Information Need in his 1 9 6 2 work The Process of asking a Question . Define this term and then discuss the importance of this feature of...
-
Write a character analysis in which you discuss three personality traits for either Binceta in "Good Girls Are Bad News" or Michael Obi in "Dead Man's Path." Also include three quotations.
-
In the series connection below, what are the respective power consumptions of R, R2, and R3? R R www 4 V=6V P1-3 W; P2=3W; and P3= 3 W OP10.5 W; P2-1 W; and P3= 1.5 W P1=1.5 W; P2=1 W; and P3= 0.5 W...
-
What is an overnight reverse repurchase agreement (ON RRP)? What role does the interest on ON RRP play in the way the Fed hits its target for the federal funds rate in the current ample-reserves...
-
A Federal Reserve publication observed that today, the The Feds primary tool for adjusting the federal funds rate is interest on reserve balances. a. Briefly explain the reasoning behind this...
-
In the following graph of the federal funds market, briefly explain whether the banking system is in a scarce reserves regime or an ample-reserves regime. In this situation, briefly explain whether...
Study smarter with the SolutionInn App