Hello, this is my first code assignment. Our instructor gave us a list of steps to complete after creating a Balloon, but I can't get past just creating it. Search results have brought up other Balloon thread, however I couldn't find a topic about issues just creating the balloon.
package myprojects; public class BalloonTester { public static void main(String[] args) { Balloon redBalloon = new Balloon("Red Balloon", 100); int Altitude ; String Name ; Name = redBalloon.getName() ; Altitude = redBalloon.getAltitude() ; System.out.println(Name); System.out.println(Altitude); } }
When I compile and run it generates the following in the output.
ant -f D:\\Users\\PLACEHOLDER\\Documents\\School\\Program ming\\MyProjects -Dnb.internal.action.name=run run
init:
Deleting: D:\Users\PLACEHOLDER\Documents\School\Programming\ MyProjects\build\built-jar.properties
deps-jar:
Updating property file: D:\Users\PLACEHOLDER\Documents\School\Programming\ MyProjects\build\built-jar.properties
Compiling 2 source files to D:\Users\PLACEHOLDER\Documents\School\Programming\ MyProjects\build\classes
D:\Users\PLACEHOLDER\Documents\School\Programming\ MyProjects\src\myprojects\BalloonTester.java:21: error: cannot find symbol
Balloon redBalloon = new Balloon("Red Balloon", 100);
symbol: class Balloon
location: class BalloonTester
D:\Users\Davi\Documents\School\Programming\MyProje cts\src\myprojects\BalloonTester.java:21: error: cannot find symbol
Balloon redBalloon = new Balloon("Red Balloon", 100);
symbol: class Balloon
location: class BalloonTester
2 errors
D:\Users\PLACEHOLDER\Documents\School\Programming\ MyProjects\nbproject\build-impl.xml:920: The following error occurred while executing this line:
D:\Users\PLACEHOLDER\Documents\School\Programming\ MyProjects\nbproject\build-impl.xml:260: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
Edit: The following is the Balloon class, our instructions were not the edit this class in anyway.
/** * A class to represent a hot-air balloon. Balloon objects have a name and an * altitude. */ public class Balloon { // instance variables private String name ; // name of the balloon private int altitude; // altitude (height) of balloon in meters /** * Create a ballon object with a given name at a given altitude. * @param theName the name of the ballon object * @param theAltitude the altitude */ public Balloon(String theName, int theAltitude) { name = theName ; // make sure altitude is not negative! altitude = Math.max(theAltitude,0) ; } /** * Ascend to a particular altitude. * @param newAlt the altitude to which to ascend, in meters. */ public void ascendTo(int newAlt) { // ascend to new altitude only if it is greater than current altitude, if (newAlt > altitude) { altitude = newAlt ; } } /** * Descend to a particular altitude. * @param newAlt the altitude to which to descend, in meters. */ public void descendTo(int newAlt) { // prevent possible crash into ground if (newAlt < 0) // if desired altitude is below ground level! { altitude = 0 ; // ...descend only to ground level } // otherwise, descend only if new altitude is less than current altitude else if (newAlt < altitude) { altitude = newAlt ; } } /** * Modify altitude by a given number of meters, up or down. * @param change number of meters to add to current altitude */ public void adjustAltitude(int change) { // if change is negative (i.e. descending), can't go below 0 altitude if (change + altitude < 0) // change < 0 && abs(change) > altitude { altitude = 0 ; // ...descend only to ground level } else // safe to modify current alt by "change" meters { altitude = altitude + change ; } } /** * Get ballon name. * @return the name of the balloon */ public String getName() { return name ; } /** * Get current altitude. * @return the altitude of the balloon */ public int getAltitude() { return altitude ; } } // end of Balloon class definition