Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer this question keeping the rules at the bottom in mind. Thank you. A class ClassB is both abstract and a child of ClasSA,
Please answer this question keeping the rules at the bottom in mind. Thank you.
A class ClassB is both abstract and a child of ClasSA, where Cl assA is concrete. ClassA owns one instance variable: a double called a. Meanwhile, ClassB also owns one double instance variable called b. In the space below, provide the equals method for ClassA and Cl assB. Base classes you design will provide - the foundational version of equals that performs the null and getclass checks - an appropriate base class version of the clone method (see Additional Notes below for further details.) When your class defines and/or inherits instance variables, it will provide - standard and copy constructors, - accessor and mutator methods for variables it defines, - an overridden version of the clone method - an overridden version of equals (See "Additional Notes" below for further details and exceptions to these rules.) In addition, the following standards will be met: - all constructor, accessor and mutator methods will employ deep copying, as appropriate - when instance variables are objects, your constructor and mutator will check for null, with constructors throwing IllegalArgumentException objects as needed and mutators returning true or false, as appropriate - when instance variables have restrictions on their values, your constructor will throw IllegalArgumentException objects as needed and mutators will return true or false, as appropriate - when a class must implement a method where the signature is predetermined (as with an inter face), it will employ global variables as needed, using the g_ notation and providing private or protected set and reset methods (protected status is needed when the class will be part of an inheritance hierarchy) and always returning the object to default state via the reset method when the global variables are not being used (null for objects, 0 . for floating point or integer variables, false for booleans) - global variables will not offer mutator methods but may offer protected accessor methods, as appropriate Additional Notes: - If your class is abstract, the clone method will likewise be abstract - If your class is concrete and is without instance variables, the clone method will return this; - If your class owns only public static final instance variables (either by declaring them itself or by inheriting only this type of instance variable) and is concrete, its clone method will return this; - If your class owns only public static instance variables (either by declaring them itself or by inheriting only this type of instance variable), it will not require a constructor and its copy constructor will simply call the copy constructor of its parent, if such a copy constructor exists (otherwise, no copy constructor is needed, either) - public static final instance variables require no accessor or mutator methods - All instance variables will be declared as private unless there is a compelling reason not to do so - child classes will therefore use accessors and mutators to work with these inherited variables - Custom exceptions having instance variables will normally not require mutator methods for these variables - they will be assigned values in the constructor only - but will include the other components, including copy constructor, the clone method and an overridden version of equalsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started