Introduction: In this project, we are going to practice utilizing inheritance and interfaces in conjunction. We...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Introduction: In this project, we are going to practice utilizing inheritance and interfaces in conjunction. We will be working with multiple geometric shapes and implementing their behaviors. Create a project in Eclipse named Project3. We will be starting with low dimensional geometric shapes and then creating an inheritance hierarchy that increases dimensionality as you move down it. For example, a cube is a three- dimensional square, a sphere is a three-dimensional circle, and a glome is a four-dimensional circle. The circle, sphere, cylinder, and glome all share the attribute radius. The square and cube share the attribute length. Follow the inheritance and interfaces as described in the table below. Finally, to test your classes, you will be writing JUnit tests for each class. Note for projects 1-5, you must submit work to Canvas once during the first 7 days of when the project was assigned to show progress towards completion (please see the rubric). Requirements: Your program will consist of the following classes: Shape, Circle, Square, Cylinder, Sphere, Cube, and Glome. Your program will also consist of two interfaces: Area and Volume. Your classes may only have the instance variables and methods explicitly specified as well as the methods that need implemented from the two interfaces. Methods Interface Area Volume double getArea() double getVolume() Class Instance Constructor Methods Extends Implements Properties Shape String name Shape(String name) Circle double radius Circle(double Square double length Cylinder double height radius, String name) Square(double Overrides getName, Shape equals, and toString Area Overrides getName, Shape Area length, String name) Cylinder(double height, double equals, and toString Overrides equals and toString Circle Volume radius, String name) Sphere None Sphere(double Overrides toString Circle Volume radius, String name) Cube None Cube(double length, Overrides toString Square Volume String name) Glome None Glome(double Overrides toString Sphere Volume radius, String name) The shape class's instance property is protected not private. You will implement the methods specified in the Area and Volume interfaces and have them return the appropriate value for each shape. Class Shape is an abstract class and will have a single public abstract method called getName() that returns a String. All shapes inherit getName() from the superclass Shape. The Circle and Square classes override it. You must write getters and setters for all instance properties where applicable. When an instance property is private, the child classes cannot access the variable directly. Therefore, the child classes must use the getters to access the values stored in the instance properties of the parent classes. The equals(Object o) method compares based on the shape properties (instance properties). Compare all instance properties that the class defines as well as those it inherits from the parent class. For example, the Cylinder class needs to compare the name, radius, and height. The Shape class can have a constructor (like a normal constructor) to set the name. Then, the child classes which extend Shape can set the name inside their constructors by using the super keyword. The toString() method returns a String with the name of the class and value of the instance properties (such as name, radius, etc.). Example String returns are as follows: "Circle [Name: Circlel, Radius: 5.0]", "Cube [Name: Cubel, Length: 10.0]", "Cylinder [Name: Cylinder2, Height: 10.0, Radius: 15.0]", "Glome [Name: Glome3, Radius: 10.0]". ⚫ The volume of a glome is 0.5 * (²) * (14) where r is the radius. Class Project3Driver: The Project3Driver class should contain the following methods: public static void main(String[] args) - This is the main method that will run your program. You are to include basic testing functionality which shows an example of your program functioning. That is, include the instantiation of an object of each type and utilize their methods via System out prints. JUnit Tester Classes: Create a JUnit test class for all classes (not for the abstract class or interfaces) you defined. In each tester class, you must test all the methods of the classes including constructors and the remaining public interface methods. You can create multiple objects of the class for testing purposes. When you test, you need to make sure you think about all possible scenarios (edge cases) for each individual method. See the posted Week 5 Lecture Code for examples. JavaDoc Style Comments: You are required to make JavaDoc comments for all classes (including the tester classes) and methods including parameters and return descriptions. Submit your java files (Project3Driver.java, Shape.java, Area.java, Volume.java, Circle.java, Circle Tester.java, Square.java, Square Tester.java, Cube.java, Cube Tester.java, Sphere.java, Sphere Tester.java, Cylinder.java, CylinderTester.java, Glome.java, and GlomeTester.java) to the corresponding Project 3 assignment's CODE plugin. Rubric: Task Grade Shape (Abstract Class) Abstract class and abstract method declaration 3 Constructor correctly implemented 3 Volume (Interface) Interface declaration getVolume() abstract method signature 3 3 Area (Interface) Interface declaration 3 3 getArea() abstract method signature Inherits Shape and implements Area Constructor correctly implemented getName() method implemented equals() method implemented Circle 2 3 2 2 toString() method implemented 2 getArea() method implemented Getters and setters correctly implemented Inherits Shape and implements Area 2 1 Square 2 Constructor correctly implemented 3 getName() method implemented 2 equals() method implemented 2 toString() method implemented 2 getArea() method implemented 2 Getters and setters correctly implemented 1 Cylinder Inherits Circle and implements Volume 2 Constructor correctly implemented 3 equals() method implemented 2 toString() method implemented 2 getVolume() method implemented 2 Getters and setters correctly implemented 1 Sphere Inherits Circle and implements Volume Constructor correctly implemented 2 3 toString() method implemented 2 getVolume() method implemented 2 Cube Inherits Square and implements Volume Constructor correctly implemented toString() method implemented getVolume() method implemented Inherits Sphere and implements Volume Glome 2 2322 2322 Constructor correctly implemented toString() method implemented getVolume() method implemented Testing with JUnit Test constructors and getName() Test equals() and toString() methods Test getArea() and getVolume() methods JavaDoc style comments for each method and class present and followed the Miami University coding guidelines Provided an intermediate submission with noticeable progress. Total JavaDoc and Intermediate Submission 1 22 5 5 100 Introduction: In this project, we are going to practice utilizing inheritance and interfaces in conjunction. We will be working with multiple geometric shapes and implementing their behaviors. Create a project in Eclipse named Project3. We will be starting with low dimensional geometric shapes and then creating an inheritance hierarchy that increases dimensionality as you move down it. For example, a cube is a three- dimensional square, a sphere is a three-dimensional circle, and a glome is a four-dimensional circle. The circle, sphere, cylinder, and glome all share the attribute radius. The square and cube share the attribute length. Follow the inheritance and interfaces as described in the table below. Finally, to test your classes, you will be writing JUnit tests for each class. Note for projects 1-5, you must submit work to Canvas once during the first 7 days of when the project was assigned to show progress towards completion (please see the rubric). Requirements: Your program will consist of the following classes: Shape, Circle, Square, Cylinder, Sphere, Cube, and Glome. Your program will also consist of two interfaces: Area and Volume. Your classes may only have the instance variables and methods explicitly specified as well as the methods that need implemented from the two interfaces. Methods Interface Area Volume double getArea() double getVolume() Class Instance Constructor Methods Extends Implements Properties Shape String name Shape(String name) Circle double radius Circle(double Square double length Cylinder double height radius, String name) Square(double Overrides getName, Shape equals, and toString Area Overrides getName, Shape Area length, String name) Cylinder(double height, double equals, and toString Overrides equals and toString Circle Volume radius, String name) Sphere None Sphere(double Overrides toString Circle Volume radius, String name) Cube None Cube(double length, Overrides toString Square Volume String name) Glome None Glome(double Overrides toString Sphere Volume radius, String name) The shape class's instance property is protected not private. You will implement the methods specified in the Area and Volume interfaces and have them return the appropriate value for each shape. Class Shape is an abstract class and will have a single public abstract method called getName() that returns a String. All shapes inherit getName() from the superclass Shape. The Circle and Square classes override it. You must write getters and setters for all instance properties where applicable. When an instance property is private, the child classes cannot access the variable directly. Therefore, the child classes must use the getters to access the values stored in the instance properties of the parent classes. The equals(Object o) method compares based on the shape properties (instance properties). Compare all instance properties that the class defines as well as those it inherits from the parent class. For example, the Cylinder class needs to compare the name, radius, and height. The Shape class can have a constructor (like a normal constructor) to set the name. Then, the child classes which extend Shape can set the name inside their constructors by using the super keyword. The toString() method returns a String with the name of the class and value of the instance properties (such as name, radius, etc.). Example String returns are as follows: "Circle [Name: Circlel, Radius: 5.0]", "Cube [Name: Cubel, Length: 10.0]", "Cylinder [Name: Cylinder2, Height: 10.0, Radius: 15.0]", "Glome [Name: Glome3, Radius: 10.0]". ⚫ The volume of a glome is 0.5 * (²) * (14) where r is the radius. Class Project3Driver: The Project3Driver class should contain the following methods: public static void main(String[] args) - This is the main method that will run your program. You are to include basic testing functionality which shows an example of your program functioning. That is, include the instantiation of an object of each type and utilize their methods via System out prints. JUnit Tester Classes: Create a JUnit test class for all classes (not for the abstract class or interfaces) you defined. In each tester class, you must test all the methods of the classes including constructors and the remaining public interface methods. You can create multiple objects of the class for testing purposes. When you test, you need to make sure you think about all possible scenarios (edge cases) for each individual method. See the posted Week 5 Lecture Code for examples. JavaDoc Style Comments: You are required to make JavaDoc comments for all classes (including the tester classes) and methods including parameters and return descriptions. Submit your java files (Project3Driver.java, Shape.java, Area.java, Volume.java, Circle.java, Circle Tester.java, Square.java, Square Tester.java, Cube.java, Cube Tester.java, Sphere.java, Sphere Tester.java, Cylinder.java, CylinderTester.java, Glome.java, and GlomeTester.java) to the corresponding Project 3 assignment's CODE plugin. Rubric: Task Grade Shape (Abstract Class) Abstract class and abstract method declaration 3 Constructor correctly implemented 3 Volume (Interface) Interface declaration getVolume() abstract method signature 3 3 Area (Interface) Interface declaration 3 3 getArea() abstract method signature Inherits Shape and implements Area Constructor correctly implemented getName() method implemented equals() method implemented Circle 2 3 2 2 toString() method implemented 2 getArea() method implemented Getters and setters correctly implemented Inherits Shape and implements Area 2 1 Square 2 Constructor correctly implemented 3 getName() method implemented 2 equals() method implemented 2 toString() method implemented 2 getArea() method implemented 2 Getters and setters correctly implemented 1 Cylinder Inherits Circle and implements Volume 2 Constructor correctly implemented 3 equals() method implemented 2 toString() method implemented 2 getVolume() method implemented 2 Getters and setters correctly implemented 1 Sphere Inherits Circle and implements Volume Constructor correctly implemented 2 3 toString() method implemented 2 getVolume() method implemented 2 Cube Inherits Square and implements Volume Constructor correctly implemented toString() method implemented getVolume() method implemented Inherits Sphere and implements Volume Glome 2 2322 2322 Constructor correctly implemented toString() method implemented getVolume() method implemented Testing with JUnit Test constructors and getName() Test equals() and toString() methods Test getArea() and getVolume() methods JavaDoc style comments for each method and class present and followed the Miami University coding guidelines Provided an intermediate submission with noticeable progress. Total JavaDoc and Intermediate Submission 1 22 5 5 100
Expert Answer:
Answer rating: 100% (QA)
Shape is the base class for all other shapes It has a single property name and a constructor that se... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
a) Outline the Rostow Stages Theory of Economic Development. (10 Marks) b) Discuss the criticisms of linear models of Economic Development (5Marks)
-
a. Example 13-1: Batch Reactor with an Exothermic Reaction Wolfram 1. Adiabatic Case: Use Wolfram to see whether you can find a trajectory that is ready to ignite and whose trajectory looks like a...
-
A solid of constant density is bounded below by the plane z = 0, on the sides by the elliptical cylinder x 2 + 4y 2 = 4, and above by the plane z = 2 - x. a. Find x and y. b. Evaluate the integral...
-
Prepare summary journal entries to record the following transactions and events a through h for a company in its first month of operations. a. Raw materials purchased on account, $90,000. b. Direct...
-
Why is it difficult to interpret a difference between how much expense was budgeted and how much was actually spent?
-
Discuss the assumptions and advantages of multistage compression.
-
Three point charges are located as shown in Fig. 3.38, each a distance a from the origin. Find the approximate electric field at points far from the origin. Express your answer in spherical...
-
Question 2 ( 2 points ) Barnes Corp. issues $ 8 0 0 , 0 0 0 of 9 % , 2 0 - year bonds. The bonds are dated January 1 , 2 0 1 1 , and are due in 2 0 years on January 1 , 2 0 3 1 . Interest is paid...
-
On July 1 of this year, R. Green established the Green Rehab Clinic. The organizations account headings are presented below. Transactions completed during the month of July follow. a. Green deposited...
-
How many significant figures are there in each of the following numbers: a) 0.006 L and 0.0605 dm b) 60.5 and 605.5 c) 960 x 10-3g and 6kg d) 60 m
-
Describe 3 ways organizations can cultivate a supportive environment in which people feel free to disagree and are encouraged to work constructively toward a mutually acceptable compromise, and how...
-
The right to die is a touchy subject for most people. In my personal experience people are always hesitant about the Living Will. It is such a serious document. Going through and deciding which...
-
Recall hash puzzles from Lecture 10. In this question, we will see how they work in practice. This question requires programming in a language that has an implementation of SHA-256 hash function. You...
-
Describe the main differences between primary data and secondary data. (b) Explain TWO (2) methods to collect primary and secondary data.
-
Rights and Obligations Contract can modify rights and obligations of creditor and guarantor to avoid some obligations Exemption clauses Continuing guarantee Allow creditor to discharge security...
-
a) Calculate the drilling cost in terms of $/ft resulted from this bit run. Bit cost: $10,000 Equipment (stabilizer): $1000 Mud: $30,000 Drilling time: 30 hr (one bit life) Trip time: 8 hr Lost time...
-
10m solution. If Ka(HA) = 10 then pOH of solution will be [Given : log4=0.6] (A) 6.7 (B) Greater than 6.7 & less than 7.0 (C) Greater 7.0 & less than 7.3 (D) Greater than 7.3
-
Derive Equation. d 2 yd 2 n 2 yn=0 by 2dy/d, rearrange to get dd(dyd) 2 =n 2 yn 2 dyd and solve using the boundary conditions dy/d = 0 at = 0.
-
The reaction A+BC is carried out adiabatically in a constant-volume batch reactor. The rate law is -rA=k1CA1/2CB1/2-k2CC Plot and analyze the conversion, temperature, and concentrations of the...
-
The reaction A+B2C is carried out in a packed-bed reactor. Match the following temperature and conversion profiles for the four different heat-exchange cases: adiabatic, constant Ta, cocurrent...
-
What is the genetic code? a. The relationship between a three-base codon sequence and an amino acid or the end of translation b. The entire base sequence of an mRNA molecule c. The entire sequence...
-
Lets suppose a researcher mixed together nucleotides with the following percentages of bases: 30% G, 30% C, and 40% A. If RNA was made via polynucleotide phosphorylase, what percentage of the codons...
-
If a tRNA has an anticodon with the sequence 3-GAC-5, which amino acid does it carry? a. Aspartic acid c. Leucine b. Valine d. Glutamine
Study smarter with the SolutionInn App