Question
Create a Java project titled hw2project, click the src icon and create a package called weather.Create 5 classes within the weather package: Sky, Cloud, StratusCloud,
Create a Java project titled "hw2project", click the src icon and create a package called "weather".Create 5 classes within the weather package: Sky, Cloud, StratusCloud, CumulusCloud, and CirrusCloud. The class names, as well as the package name, must be spelled and capitalized exactly as shown here
Cloud.java This class needs:
1) Private float instance variables: bottom and top. 2) A ctor that takes bottom and top as args and stores them in the instance variables. NOTE: ctor is an abbreviation for constructor. 3) A public method getHeight() that returns a float, whose value is top minus bottom. 4) A public String method rain() that returns It is raining
StratusCloud.java and CumulusCloud.java For these classes: 1) Change the class declarations so that they are subclasses of Cloud. 2) Fix the ctors so that they pass bottom and top to the superclass ctor. CirrusCloud.java Subclasses of Cloud inherit a rain() method that is not appropriate for cirrus clouds. Override rain() so that it returns I cannot make rain
Sky.java This class holds lots of cloud instances of various types, and computes the average cloud height. It needs: 1) A private ArrayList
Sky2.java Lastly, implement Sky in a somewhat different way. When one class holds many references to instances of another class, we say (for example) that Sky aggregates clouds. Sky aggregates by owning an array list. Sky2 will aggregate by being (in a sense) an array list. That is, Sky2 will extend ArrayList
Finally, export your work as a jar file called CS46BHW2.jar.
Step 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