Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer both parts of these questions. The golden rules are posted below. Thank you. A class called ChemicalPlant owns an instance variable called distillationcolumns

Please answer both parts of these questions. The "golden rules" are posted below. Thank you.image text in transcribedimage text in transcribedimage text in transcribed

A class called ChemicalPlant owns an instance variable called distillationcolumns consisting of an array of DistillationColumn objects, where the DistillationColumn class itself adheres to our Golden Rules. In the box below, enter the standard constructor for Chemical Plant. Consider once more the class ChemicalPlant that owns the instance variable called distillationcolumns consisting of an array of DistillationColumn objects, where the DistillationColumn class itself adheres to our Golden Rules. This time, however, the array distillationColumns cannot contain more than 5 DistillationColumn elements. In the box below, enter the distillationColumns mutator for ChemicalPlant. 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 equals

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are Electrophoresis?

Answered: 1 week ago