![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2004
Posts: 29
Rep Power: 0
![]() |
Hello,
For a class I need to create an Airport Traffic Control Program. The airport needs to have a number of runways that is determined at runtime. In order to keep track of the runways I want to create an array of these runways. I have a runway class declared. How can I create an array of these runway objects in a different class? It has been way too long since I've programmed in Java. Could anyone help? Thank you. |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Runway runway[] = new Runway[5]; //just using 5 as an example
for(int i = 0; i<runway.length; i++)
{
runway = new Runway();
}
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2004
Posts: 29
Rep Power: 0
![]() |
Thanks.
Now I have another problem though... Later in my Airport class I have a method getNumRunways where I'm trying to return the length of the runway array using return runway.length The error I get when I try this is: C:\Documents and Settings\Mindwalker1\My Documents\CS 161\Airport\Airport.java:71: cannot find symbol symbol : variable runway location: class Airport return runway.length; ^ 1 error Thanks |
|
|
|
|
|
#4 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
I have to go eat. Could you please post the code, and I'll come back and take a look.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Sep 2004
Posts: 29
Rep Power: 0
![]() |
Never mind, I solved it.
I had forgotten to declare the array outside of the method. Solved now. |
|
|
|
|
|
#6 |
|
Programming Guru
![]() ![]() ![]() |
Bummer... I missed something that half-way sounded interesting.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|