Study the UML diagram from Figure 1. Create an abstract class Shape and class Coordinates. Class...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Study the UML diagram from Figure 1. Create an abstract class Shape and class Coordinates. Class Coordinates has two fields-an array of X-coordinates and an array of Y-coordinates. The size of the arrays is defined by the static constant MAX_VERT which holds the maximum number of vertices a shape in the project may have. The relationship between these two classes is an aggregation: "Shape has Coordinates." Field shape in class Shape holds the type of each object created. Possible types are Line, Triangle, and Parallelogram. It is recommended to create an enumerated class ShapeType for possible types of shapes. Such a class may be defined inside the class Shape or as a separate file. If you experience difficulties with enumerated types, you can use an array of strings instead. Static method distance () in class Shape returns the distance between two points given by its coordinates. It can be used by any derived class. Make method perimeter () in class Shape an abstract method, so any derived class has to implement it. enum ShapeType Line Triangle Parallelogram Line +Line(coord: Coordinates) perimeter():double +toString(): String Shape #shape: ShapeType #coord: Coordinates +Shape(coord: Coordinates) +distancefxl.v1 2.v2.indouble perimeter():double +toString():String Triangle +Triangle(coord: Coordinates) perimeter():double +toString() String Coordinates -MAX VERT int +x:int[] +y:int Coordinates(x,y:int[]) Parallelogram +Parallelogram(coord: Coordinates) +perimeter():double +isRectangle():boolean +toString(): String Study the UML diagram from Figure 1. Create an abstract class Shape and class Coordinates. Class Coordinates has two fields-an array of X-coordinates and an array of Y-coordinates. The size of the arrays is defined by the static constant MAX_VERT which holds the maximum number of vertices a shape in the project may have. The relationship between these two classes is an aggregation: "Shape has Coordinates." Field shape in class Shape holds the type of each object created. Possible types are Line, Triangle, and Parallelogram. It is recommended to create an enumerated class ShapeType for possible types of shapes. Such a class may be defined inside the class Shape or as a separate file. If you experience difficulties with enumerated types, you can use an array of strings instead. Static method distance () in class Shape returns the distance between two points given by its coordinates. It can be used by any derived class. Make method perimeter () in class Shape an abstract method, so any derived class has to implement it. enum ShapeType Line Triangle Parallelogram Line +Line(coord: Coordinates) perimeter():double +toString(): String Shape #shape: ShapeType #coord: Coordinates +Shape(coord: Coordinates) +distancefxl.v1 2.v2.indouble perimeter():double +toString():String Triangle +Triangle(coord: Coordinates) perimeter():double +toString() String Coordinates -MAX VERT int +x:int[] +y:int Coordinates(x,y:int[]) Parallelogram +Parallelogram(coord: Coordinates) +perimeter():double +isRectangle():boolean +toString(): String
Expert Answer:
Answer rating: 100% (QA)
Heres the implementation for the Shape and Coordinates classes as per the instructions given in Step 1 public abstract class Shape protected ShapeType type protected Coordinates coordinates public Sha... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Briefly list the major administration tasks you can handle to manage a database in cloud. . QUESTION 12 List the major components of email system. QUESTION 13 In a job interview, you are...
-
a. You have created several classes for Sammys Seashore Supplies. Now, Sammy has decided to restructure his rates to include different fees for equipment types in addition to the fees based on rental...
-
We will begin to practice OOD by extending one of the JavaFX classes (Point2D) into an abstract LocalPoint class we will create using inheritance and implementing a standardising interface we will...
-
What is the output of the following? A. 1223445 B. 2445 C. 22445 D. 223445 E. 2233445 F. None of the above. public class InitOrder { } {System.out.print("1"); } static System.out.print("2"); } public...
-
A container of weight W is suspended from ring A, to which cables AC and AE are attached. A force P is applied to the end F of a third cable which passes over a pulley at B and through ring A and...
-
Kroger Co. is one of the largest retail food companies in the United States as measured by total annual sales. The Kroger Co. operates supermarkets, convenience stores, and manufactures and processes...
-
For each of the following variables, identify whether you could use a pie chart, bar chart, histogram, or frequency polygon to visually display the data: a. Shoe size b. College major c. Favorite...
-
On December 31, 2017, Ball Company leased a machine from Cook for a 10-year period, expiring December 30, 2027. Annual payments of $100,000 are due on December 31. The first payment was made on...
-
Pharoah Industries produces and sells a cell phone-operated home security control systems. Information regarding the costs and sales during May 2022 is as follows. Unit selling price $45.00 Unit...
-
Storage of perishable items is an important concern for many companies. One study examined the effects of storage time and storage temperature on the deterioration of a particular item. Three...
-
Convert the complex number z=, ei(-) to rectangular form. 3V3 i 2 3V3 3 2 3V3 i 2 3V3 +2i
-
Think of five brand names. To what extent do they meet the criteria of good brand naming as laid out in Table 6.1? Do any of the names legitimately break these guidelines? Table 6.1 Brand name...
-
Review the choice criteria influencing some recent purchases, such as a hairstyle, a meal, etc.
-
Tim is opening a new online store. He plans to hire two workers at $10 an hour. Tim is also considering buying or leasing some new computers. The purchase price of a computer is $900 and after three...
-
a. Find Wandas demand for labor curve. b. How many students does Wandas employ? Wandas is a fish store that hires students to pack the fish. Students can pack the following amounts of fish: The fish...
-
Why does Mammas Pizza have excess capacity in the long run and can it be avoided? which shows the situation facing Mammas Pizza, a pizzeria, to work Problems. The demand and costs of other pizzerias...
-
please answer all The amide formed in the reaction of benzoic acid and ethylamine is NHCH3 O OH NHCHCH3 CNHCHCH3 ONHCH,CH3
-
Suppose you need to answer any four of seven essay questions on a history test and you can answer them in any order. a. How many different question combinations are possible? b. What is the...
-
Write a program that reads a connected graph from a file. The graph is stored in a file using the same format specified in Programming Exercise. Your program should prompt the user to enter the name...
-
Write a program that prompts the user to enter two strings and reports whether the second string is a substring of the first string. Enter string sl: ABCD Enter string s2: BC substring of ABCD -...
-
Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects. Draw the UML...
-
A \(40-\mathrm{cm}-\) long tube has a \(40-\mathrm{cm}-\) long insert that can be pulled in and out, as shown in Figure P16.59. A vibrating tuning fork is held next to the tube. As the insert is...
-
The width of a particular microwave oven is exactly right to support a standing-wave mode. Measurements of the temperature across the oven show that there are cold spots at each edge of the oven and...
-
A \(12 \mathrm{~kg}\) hanging sculpture is suspended by a \(90-\mathrm{cm}-\) long, \(5.0 \mathrm{~g}\) steel wire. When the wind blows hard, the wire hums at its fundamental frequency. What is the...
Study smarter with the SolutionInn App