For this problem, you're going to implement a small fragment of the image library you've been...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
For this problem, you're going to implement a small fragment of the image library you've been using for Fundies 1 and 2. Each picture is either a single Shape or a Combo that connects one or more pictures. Each Shape has a kind, which is a string describing what simple shape it is (e.g., "circle" or "square"), and a size. (For this problem, we will simplify and assume that each simple shape is as tall as it is wide.) A Combo has two fields: a name describing the resulting picture, and an operation which specifies how this image was put together. There are three kinds of operations: Scale (has a single picture to scale twice as large as the original), Beside (has two pictures to draw: picture1 to the left of picture2), and Overlay (has two pictures to draw top-picture on top of bottom-picture, with their centers aligned). Sketch the class diagrams for the classes and interfaces you will need to represent the information above. (You can draw this on paper, or in ASCII art as a comment in your submitted file. You do not need to hand this in, but doing this step will help clarify how the interfaces and classes are related to each other.) Design the classes (and interfaces) needed to represent the given information. In the Examples Picture class define example data that represents the following images (the colors don't matter; they're just for illustration here): a single circle of size 20 a single square of size 30 O A circle - o A square - A big circle - 2 the result of scaling circle o A square on circle- o A doubled square on circle - DO You should define each picture by its name (e.g. square or bigCircle). Any combo image should use the description text given above as its description. Our test program will use this data to test your methods. Add to your examples one more example of picture for each of the possible operations. Do not modify the existing pictures. Design the method getwidth that computes the overall width of this picture. Hint: follow the design recipe... working through examples really helps. Design the method countShapes that computes the number of single shapes involved in producing the final image. Note: Make sure you count every shape each time it is used. Design the method comboDepth, that computes how deeply operations are nested in the construction of this picture. For example, the comboDepth of the last example picture above is 3. Design the method mirror. This should produce a picture like this one where it leaves the entire picture unchanged, except Beside combos, which should have their two sub- images flipped (all names can remain untouched). This mirroring should happen the entire way down the image. Tricky! Design the method pictureRecipe that takes an integer depth, and produces a String representing the contents of this picture, where the recipe for the picture has been expanded only depth times. For example, the pictureRecipe at depth 0 for the last example image above is "doubled square on circle", at depth 2 is "beside (overlay(square, big circle), overlay(square, big circle))", and at depth 3 or more is "beside (overlay(square, scale(circle)), overlay(square, scale(circle)))". In more detail: invoking pictureRecipe on a Combo produces its name if the given depth is less than or equal to 0, and the formula of its contents (at that depth) otherwise. Hint: If you get stuck, you may want to use a wish list to determine subproblems that may be of use to you, and that you can delegate to when needed. For this problem, you're going to implement a small fragment of the image library you've been using for Fundies 1 and 2. Each picture is either a single Shape or a Combo that connects one or more pictures. Each Shape has a kind, which is a string describing what simple shape it is (e.g., "circle" or "square"), and a size. (For this problem, we will simplify and assume that each simple shape is as tall as it is wide.) A Combo has two fields: a name describing the resulting picture, and an operation which specifies how this image was put together. There are three kinds of operations: Scale (has a single picture to scale twice as large as the original), Beside (has two pictures to draw: picture1 to the left of picture2), and Overlay (has two pictures to draw top-picture on top of bottom-picture, with their centers aligned). Sketch the class diagrams for the classes and interfaces you will need to represent the information above. (You can draw this on paper, or in ASCII art as a comment in your submitted file. You do not need to hand this in, but doing this step will help clarify how the interfaces and classes are related to each other.) Design the classes (and interfaces) needed to represent the given information. In the Examples Picture class define example data that represents the following images (the colors don't matter; they're just for illustration here): a single circle of size 20 a single square of size 30 O A circle - o A square - A big circle - 2 the result of scaling circle o A square on circle- o A doubled square on circle - DO You should define each picture by its name (e.g. square or bigCircle). Any combo image should use the description text given above as its description. Our test program will use this data to test your methods. Add to your examples one more example of picture for each of the possible operations. Do not modify the existing pictures. Design the method getwidth that computes the overall width of this picture. Hint: follow the design recipe... working through examples really helps. Design the method countShapes that computes the number of single shapes involved in producing the final image. Note: Make sure you count every shape each time it is used. Design the method comboDepth, that computes how deeply operations are nested in the construction of this picture. For example, the comboDepth of the last example picture above is 3. Design the method mirror. This should produce a picture like this one where it leaves the entire picture unchanged, except Beside combos, which should have their two sub- images flipped (all names can remain untouched). This mirroring should happen the entire way down the image. Tricky! Design the method pictureRecipe that takes an integer depth, and produces a String representing the contents of this picture, where the recipe for the picture has been expanded only depth times. For example, the pictureRecipe at depth 0 for the last example image above is "doubled square on circle", at depth 2 is "beside (overlay(square, big circle), overlay(square, big circle))", and at depth 3 or more is "beside (overlay(square, scale(circle)), overlay(square, scale(circle)))". In more detail: invoking pictureRecipe on a Combo produces its name if the given depth is less than or equal to 0, and the formula of its contents (at that depth) otherwise. Hint: If you get stuck, you may want to use a wish list to determine subproblems that may be of use to you, and that you can delegate to when needed.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these algorithms questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
QUIZ... Let D be a poset and let f : D D be a monotone function. (i) Give the definition of the least pre-fixed point, fix (f), of f. Show that fix (f) is a fixed point of f. [5 marks] (ii) Show that...
-
Parent Ltd owns 80% of Subsidiary Ltd. In the financial year ended 30 June 20X2, Subsidiary Ltd sold inventory to Parent Ltd. Details regarding the transaction are as follows: Cost to Subsidiary to...
-
The reactance of a capacitor is 68 V when the ac frequency is 460 Hz. What is the reactance when the frequency is 870 Hz?
-
Bass Corporation purchases 10 tickets to the Super Bowl in February 2023 for entertaining its customers. Due to unusually high demand, the tickets have to be purchased for \($25,000\) (10 ...
-
The magnitude of the gravitational force exerted by Earth on an object of inertia \(m_{1}\) is \(m_{1} g\). (a) What is the magnitude of the force exerted by the object on Earth (inertia...
-
Santana Rey, owner of Business Solutions, decides to prepare a statement of cash flows for her business. (Although the serial problem allowed for various ownership changes in earlier chapters, we...
-
7. The full symbol of an ion of an element is 39X+? Which one of the following is the number of electrons in the ion? A. 18 B. 19 C. 20 D. 39 8. The atomic numbers of elements W, X, Y and Z are 9,...
-
Healthwise Medical Supplies Company is located at 2400 Second Street, City, ST 12345. The company is a general partnership that uses the calendar year and accrual basis for both book and tax...
-
1. What are the different components of report? 2. Write briefly about oral presentation and its parts?
-
David, an actuary, is explaining that insurance rates should have five characteristics. Which one of the following correctly describes what David means when he says that rates should provide for...
-
The city of encumbered purchases orders and contracts of $867,000. The journal entry to record the subsequent receipt of all items and related invoices for $480,000 should include ?
-
What are value claims? Give an example of a specific purpose statement for a persuasive speech with a value claim. Pick one of the fallacies you read about this week in the weekly readings and find...
-
a. The resume is one of the main ways you can positively influence a potential employer's impression of you. list and describe four guidelines for creating an effective resume. b. The format of a...
-
Paid $360 cash for shipping charges on the April 2 purchase. Note: Enter debits before credits. Date April 03 General Journal Debit Credit
-
Consider two mutually exclusive transportation alternatives, D and E for which equivalent annual benefits to the pubik are $225milon and S on information in the table below, knowing that MARR 10% and...
-
Without solving, determine the character of the solutions of each equation in the complex number system. 3x 2 3x + 4 = 0
-
Indicate, in each of the following situations, the number of exemptions the taxpayers are entitled to claim on their 2012 income tax returns. Number of Exemptions a. Donna, a 20-year-old single...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-4. Ivan and Irene paid the following in 2012 (all by check or can otherwise be...
-
Phil and Linda are 25-year-old newlyweds and file a joint tax return. Linda is covered by a retirement plan at work, but Phil is not. a. Assuming Phil's wages were $27,000 and Linda's wages were...
-
The first three energy levels \(E(\mathrm{eV})\) of the fictitious element \(\mathrm{X}\) are \(\ldots . . \ldots\) shown in Figure P29.56. a. What wavelengths are observed in the absorption spectrum...
-
A sodium atom in the \(3 p\) state emits a photon, decreasing the energy of the atom by \(2.10 \mathrm{eV}\). By how much does the orbital angular momentum of the atom change? Does it increase or...
-
Assume instead that the spot exchange rate between the dollar and Swiss franc is a fixed or pegged rate within a narrow band around a central rate. For each change shown in Problem 9, assume that...
Study smarter with the SolutionInn App