Question: Hey guys! Can you help me with this code error? So here are the assignment directions: Create 4 other classes in the weather package: Cloud,
Hey guys! Can you help me with this code error?
So here are the assignment directions:
"Create 4 other classes in the weather package: Cloud, StratusCloud, CumulusCloud, and CirrusCloud.
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
2) A ctor that creates the clouds array list with an initial capacity of 100. Look up
the javadoc API page for ArrayList to see what ArrayList ctor to call. If you dont
know how to do this, ask on Piazza. DONT ask Piazza for the answer, just ask
how to find the javadoc API page.
3) A public method called add(Cloud c) that takes a cloud and adds it to the array
list. The return type of this method should be boolean, and the method should
always return true. Thats a little weird but it will make more sense later.
4) A public float method called getMeanHeight(), which returns the average height
of all the clouds in the array list.
5) A main() method. Paste in the following:
public static void main(String[] args)
{
StratusCloud strat = new StratusCloud(100, 1000);
if (!strat.rain().startsWith("It is raining"))
System.out.println("Bad StratusCloud::rain");
CumulusCloud cumu = new CumulusCloud(200, 2000); if (!cumu.rain().startsWith("It is raining"))
System.out.println("Bad CumulusCloud::rain");
CirrusCloud cirr = new CirrusCloud(300, 3000); if (!cirr.rain().startsWith("I cannot make"))
System.out.println("Bad CirrusCloud::rain"); Sky sky = new Sky();
sky.add(strat); sky.add(cumu); sky.add(cirr); float mean = sky.getMeanHeight(); if (mean 1801)
System.out.println("Bad mean height: expected 1800, saw " + mean);
System.out.println("Everything (else) is ok");
}
To test your work so far, run Sky as an application. Click the tiny Run button at the top of Eclipse (a white triangle pointing right, inside a green circle). The only output should be Everything (else) is ok. "
And here is my code of the StratusCloud class:

And here is my code of the Sky class:

And here's the error I get when I run the Sky class:

Any help is appreciated!!
D Sky.java D Cloud.java | | package weather; Packag : Type Hi | D StratusCloud.ja X | >"2 hw2project public class StratusCloud extends Cloud src weather public StratusCloud(float thatBottom, float thatTop) CirrusCloud.java D Cloud.java super thatBottom, thatTop); Cloud D CumulusCloud.java ED Sky.java StratusCloud.java JRE System Library [JavaSE-1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
