Β
Network Log Utility.
In this assignment we implement a Java class hierarchy which represents various twoβdimensional and threeβdimensional shapes. The hierarchy extends classes/interfaces from Javaβs API and defines new abstract and concrete classes. As a start, I am providing the classβ stubs without any implementation. You may choose to write your implementation without relying on the provided stubs; however, please adhere to the naming conventions shown in the UML diagram. A test class is provided for this assignment. You will be graded on the efficiency of your code; reuse parent implementation whenever possible. Please submit a ZIP file containing your 6 classes.
Preamble
From Javaβs API we will utilize a number of classes including:
- πππππππ‘, a class for maintaining a collection of objects in a sorted fashion. Using πππππππ‘ is similar to using an π΄ππππ¦πΏππ π‘. The πππππππ‘ works best with objects that implement the πΆπππππππππ
- πΆπππππππππ, a generic type interface (i.e. template); classes that implement this interface are forced to implement the method πππππππππ. The πππππππππ defines how two objects of the same type are compared. The basic implementation of the πππππππππ is to, first, decide on how to compare two objects and, second, return either: ΓΌ A 0 if two objects are deemed equivalent.
- A negative number if the left object is smaller than the right object
- A positive number if the left object is greater than the right object
Here is an example which compares two class objects based on the ππππ π‘ and π πππππ fields respectively. Two objects of type ππ¦πΆπππ π are deemed equal if their ππππ π‘ and π πππππ values are the same. If the ππππ π‘ fields are not equal, the result of πππππππππ are based on comparing the ππππ π‘ fields only. However, if the ππππ π‘ fields are equal, the result of πππππππππ is based on the comparison between the π πππππ fields.
| // πππ‘π π‘βπ ππππ π ππππ πππ‘π€πππ πππππ πππππππ‘π |
ππ’ππππ ππππ π ππ¦πΆπππ π πππππππππ‘π πΆπππππππππΒ Β Β Β Β ππ¦πΆπππ π
πππ‘ ππππ π‘;
ππ‘ππππ π πππππ;
@ππ£ππππππ
ππ’ππππ πππ‘ πππππππππ ππ¦πΆπππ π ππ‘βππ
Β
πππ‘ πππ π’ππ‘ Β Β Β Β Β Β Β Β πΌππ‘ππππ. πππππππ ππππ π‘, ππ‘βππ. ππππ π‘ ;
Β
| // ππ π‘βπ ππππ π‘ ππππππ πππ‘πβ, πππ π’ππ‘π πππ πππ ππ ππ πππππππππ π‘βπ π πππππ ππππππ |
ππ πππ π’ππ‘ Β Β Β Β Β Β Β Β Β Β 0
| // πππ π’ππ‘ ππ πππ ππ ππ πππππππππ π‘βπ π πππππ ππππππ |
πππ‘π’ππ π πππππ. πππππππππ ππ‘βππ. π πππππ ;
Β
Β
| // βπππ π€βππ π‘βπ ππππ π‘ ππππππ ππ πππ‘ πππ‘πβ |
πππ‘π’ππ πππ π’ππ‘;
Β
Β
Classβ Description:
The assignment consists of 6 Java classes, 3 abstract and 3 nonβabstract classes and 1 test class. Class stubs are provided for an easier start.
- πΊππππ:
- An abstract class which implements Javaβs πΆπππππππππ Interface
- Contains two abstract methods, ππππ and πππππππ‘ππ.
- π‘πππ‘ππππ: returns a spaceβdelimited string of its fields:
βͺ π£πππ’π ππ ππ β« βͺ π£πππ’π ππ ππππ β« βͺ π£πππ’π ππ πππ πππππ‘πππ β« βͺ π£πππ’π ππ πππππ β«
- πππ‘πΆππππππππ: returns the name of the πΆππππ as a ππ‘ππππ. This method is simply the reverse implementation of πππ‘πΆππππ in the test class
- πππππππππ: numerically compares two objects of type πβπππ. Returns the value 0 if both objects have the same ππππ and πππππ. Use πππ‘πΆππππππππ when comparing colors. Note that the ππ and πππ πππππ‘πππ fields are excluded here. Otherwise, return the results of the first mismatch comparison between ππππ then πππππ. In other
words, if the two ππππ fields are the same return the results of comparing the two πππππ fields. II. πΊππππππ« and πΊππππππ«:
- Abstract classes which inherits from class πβπππ.
- The nonβdefault constructor initializes the classβ private fields
- π‘πππ‘ππππ: returns the same value described in the parent class but includes βπππβπ‘, π€πππ‘β, and πππππ‘β The method must reβuse the parent classβ π‘πππ‘ππππ implementation.
- πππππππππ numerically compares two objects of type πβπππ2π· (or πβπππ3π·). Returns the value 0 if both objects have the same ππ, ππππ, πππ πππππ‘πππ, π€πππ‘β, βπππβπ‘, and πππππ‘β (for πβπππ3π· only). The πππππππππ in πβπππ2π· must reβuse the πππππππππ from the πβπππ The πππππππππ in πβπππ3π· must reuse the πππππππππ from the πβππ’π’ππ2π· class.
- πππ‘π·πππππ ππππ : returns the values of the shapeβs dimensions (π€πππ‘β, βπππβπ‘, and πππππ‘β). Use precision 2 and separate each dimension with the an βπβ.
III.Β Β πΈπππ πππππππππ
- Represents 90Β° angle quadrilateral 2D shapes
- Inherits from class πβπππ
- ππππ widthΒ Β Β height
- πππππππ‘ππ 2Β Β Β Β Β Β Β Β Β Β Β Β widthΒ Β Β height
IV.Β Β πΈπππ πππππππππππ«
- Represents 90Β° angle quadrilateral 3D shapes
- ππππ 2 Β Β Β Β Β Β Β Β Β Β Β Β widthΒ Β heightΒ Β widthΒ Β Β lengthΒ Β height Β length
- πππππππ‘ππ 4Β Β Β Β Β Β Β Β Β Β Β Β widthΒ Β Β heightΒ Β length
V.Β Β Β Β Β Β πΊπππππ³πππ
- Extends πππ£π. π’π‘ππ. πππππππ‘
- πππ: checks if a similar πβπππ instance is already stored. If a similar object is found, the method returns false. If it is not, the object is added and the method returns π‘ππ’π. YOU MUST USE the ππππ‘ππππ method from πππππππ‘ which requires that the method πππππππππ is be overloaded properly. Do not write your own search code.
- πππ‘2π·πβππππ : returns a new set containing instances of supertype πβπππ2π· Hint: the πππ π‘πππππ operator is useful here.
- πππ‘3π·πβππππ : returns a new set containing instances of supertype πβπππ3π·
- πππππ‘πΉπππππ‘π‘ππ: prints a sorted and formatted table of all πβπππ objects (Figure 2). The list is automatically sorted by ππππ, then πΆππππ, then π·πππππ πππ based on the πππππππππ implementation described earlier. π¨ππ»πππ:
- This is the provided test class. Your code should work with this class AS IS. Please DO NOT modify or submit this class and adhere to the names provided in the classβ UML diagram (Figure 1). You may, however, comment lines of code until you are ready to test the methods they invoke.
- Your codeβs output should match the output shown in Figure 2
Β
Figure 1: Class UML Diagram
java.lang.UnsupportedOperationException: Unrecognized shape, skipping: 98241,BLACK,18.785:15.059,Sphere,A black sphere java.lang.UnsupportedOperationException: Unrecognized shape, skipping: 57057,BLACK,7.85:,Circle,A black sphere The list contains 29 Shape objects
There are 18 2-Dimensional shapes
There are 11 3-Dimensional shapes
+βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | IDΒ Β Β Β | NameΒ Β Β Β Β Β Β | ColorΒ Β | DimensionsΒ Β Β Β Β Β Β Β Β Β Β Β Β | DescriptionΒ Β Β Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 35779Β | CubeΒ Β Β Β Β Β Β | BlueΒ Β Β | 39.20 X 46.91 X 27.15Β Β | A blue cubeΒ Β Β Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 90238Β | CubeΒ Β Β Β Β Β Β | BlueΒ Β Β | 77.60 X 54.66 X 8.34Β Β Β | A blue cubeΒ Β Β Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 65701Β | CubeΒ Β Β Β Β Β Β | RedΒ Β Β Β | 90.33 X 56.78 X 44.61Β Β | A red cubeΒ Β Β Β Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 40433Β | CubeΒ Β Β Β Β Β Β | YellowΒ | 94.89 X 43.88 X 21.47Β Β | A yellow cubeΒ Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 51060Β | CuboidΒ Β Β Β Β | BlackΒ Β | 43.61 X 94.74 X 65.44Β Β | A black cuboidΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 90955Β | CuboidΒ Β Β Β Β | BlueΒ Β Β | 55.69 X 40.01 X 90.70Β Β | A blue cuboidΒ Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 83912Β | CuboidΒ Β Β Β Β | BlueΒ Β Β | 8.09 X 45.01 X 96.79Β Β Β | A blue cuboidΒ Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 64851Β | CuboidΒ Β Β Β Β | GreenΒ Β | 98.18 X 5.51 X 64.22Β Β Β | A green cuboidΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 88174Β | CuboidΒ Β Β Β Β | GreenΒ Β | 94.47 X 6.70 X 83.56Β Β Β | A green cuboidΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 37951Β | CuboidΒ Β Β Β Β | RedΒ Β Β Β | 70.19 X 32.90 X 94.36Β Β | A red cuboidΒ Β Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 36830Β | CuboidΒ Β Β Β Β | YellowΒ | 5.38 X 59.99 X 69.06Β Β Β | A yellow cuboidΒ Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 48900Β | RectangleΒ Β | RedΒ Β Β Β | 57.56 X 4.03Β Β Β Β Β Β Β Β Β Β Β | A red rectangleΒ Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 60665Β | RectangleΒ Β | RedΒ Β Β Β | 77.08 X 60.12Β Β Β Β Β Β Β Β Β Β | A red rectangleΒ Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 90965Β | RectangleΒ Β | RedΒ Β Β Β | 94.77 X 61.20Β Β Β Β Β Β Β Β Β Β | A red rectangleΒ Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 72916Β | RectangleΒ Β | WhiteΒ Β | 24.37 X 86.85Β Β Β Β Β Β Β Β Β Β | A white rectangleΒ Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 35886Β | RectangleΒ Β | YellowΒ | 65.95 X 51.71Β Β Β Β Β Β Β Β Β Β | A yellow rectangleΒ Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 60895Β | SquareΒ Β Β Β Β | BlackΒ Β | 87.86 X 39.68Β Β Β Β Β Β Β Β Β Β | A black squareΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 67132Β | SquareΒ Β Β Β Β | BlackΒ Β | 33.89 X 83.52Β Β Β Β Β Β Β Β Β Β | A black squareΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 44356Β | SquareΒ Β Β Β Β | BlueΒ Β Β | 57.32 X 54.03Β Β Β Β Β Β Β Β Β Β | A blue squareΒ Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 85368Β | SquareΒ Β Β Β Β | CyanΒ Β Β | 70.95 X 41.82Β Β Β Β Β Β Β Β Β Β | A cyan squareΒ Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 99999Β | SquareΒ Β Β Β Β | CyanΒ Β Β | 61.01 X 44.17Β Β Β Β Β Β Β Β Β Β | A cyan squareΒ Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 26449Β | SquareΒ Β Β Β Β | CyanΒ Β Β | 84.56 X 77.16Β Β Β Β Β Β Β Β Β Β | A cyan squareΒ Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 71002Β | SquareΒ Β Β Β Β | GreenΒ Β | 23.65 X 12.55Β Β Β Β Β Β Β Β Β Β | A green squareΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 78853Β | SquareΒ Β Β Β Β | RedΒ Β Β Β | 7.28 X 60.85Β Β Β Β Β Β Β Β Β Β Β | A red squareΒ Β Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 37376Β | SquareΒ Β Β Β Β | RedΒ Β Β Β | 63.30 X 91.52Β Β Β Β Β Β Β Β Β Β | A red squareΒ Β Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 25280Β | SquareΒ Β Β Β Β | WhiteΒ Β | 5.54 X 0.04Β Β Β Β Β Β Β Β Β Β Β Β | A white square Β Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 66544Β | SquareΒ Β Β Β Β | WhiteΒ Β | 43.07 X 30.90Β Β Β Β Β Β Β Β Β Β | A white squareΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 27982Β | SquareΒ Β Β Β Β | WhiteΒ Β | 29.25 X 88.76Β Β Β Β Β Β Β Β Β Β | A white squareΒ Β Β Β Β Β | +βββ+ββββ-+βββ+ββββββββ-+βββββββ-+ | 76667Β | SquareΒ Β Β Β Β | YellowΒ | 38.50 X 62.44Β Β Β Β Β Β Β Β Β Β | A yellow squareΒ Β Β Β Β |
+βββ+ββββ-+βββ+ββββββββ-+βββββββ-+
Figure 2: Test Classβ Output
Β
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β
UML Diagram Legend
| Symbol | Description |
| Underlined | Indicates a static member |
| Β | A private member (i.e. variable or method) |
| Β | A private final member (i.e. variable) |
| Β | A public field (i.e. variable or method) |
| Β | A public abstract member (i.e. variable or method) |
| Β | A public constructor |
| Β | A static public member |
| Β | An interface |
| Β | A public class |
| Β | A public abstract class |
| Β | A hollowed arrow indicates inheritance |
| Β | An open-ended arrow indicates composition |
| Β | A dotted line and hollowed arrow indicate class implementation |
Β
Β






