Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

+++Please Help Me

24 views
Skip to first unread message

ma...@patrol.i-way.co.uk

unread,
Jun 29, 1996, 3:00:00 AM6/29/96
to
Hello,
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Error: Hotel.java:4: Undefined variable: running
running = false;
^
Error: Hotel.java:21: No variable running defined in class Elevator.
if (!(NorthElevator.running))
^
Error: Hotel.java:25: No variable running defined in class Elevator.
if (!(SouthElevator.running))
^
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++WHEN I TRIED TO COMPILE THE TEXT BELOW I GOT THE ERRORS ABOVE
CAN YOU SUGGEST WHAT TO DO ?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++class Elevator {
boolean runnig = true;
void shutDown() {
running = false;
}
}
class FrontDesk {
private final int EVENING = 8;
Elevator NorthElevator, SouthElevator;

FrontDesk() { //the class sonstructor
NorthElevator = new Elevator();
SouthElevator = new Elevator();
}
void maintenance(int time) {
if (time == EVENING)
NorthElevator.shutDown();
}
void displayStatus() { // code is very inefficient, but serves
a purpose
System.out.print("North Elevator is ");
if (!(NorthElevator.running))
System.out.print("not ");
System.out.println("running.");
System.out.print("South Elator is ");
if (!(SouthElevator.running))
System.out.print( " not ");
System.out.println("running.");
}
}
public class Hotel {
public static void main(String args[]) {
FrontDesk lobby;
lobby = new FrontDesk();

System.out.println("It's &:00. Time to check the
elevators.");
lobby.maintenance(7);
lobby.displayStatus();

System.out.println();
System.out.println("It's 8:00. Time to check the
elavators.");
lobby.maintenance(8);
lobby.displayStatus();
}
}

Geert Vernaeve

unread,
Jun 30, 1996, 3:00:00 AM6/30/96
to

ma...@patrol.i-way.co.uk wrote:
: CAN YOU SUGGEST WHAT TO DO ?
: class Elevator {
: boolean runnig = true;

Try
a) changing "runnig" to "running" (forgot an n)
b) making the variable public, i.e. change the line into
"public boolean running = true"
(I don't know the scoping reules by heart, but it could be that the
standard visibility is: not visible for other classes -- but I may
be wrong...)

Geert.

NEC SPE Geert.V...@rug.ac.be NEC METU
ge...@einstein.rug.ac.be
http://studwww.rug.ac.be/~gvernaev

Joseph Millar

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

ma...@patrol.i-way.co.uk wrote:
> Error: Hotel.java:4: Undefined variable: running
> running = false;
> ^
> Error: Hotel.java:21: No variable running defined in class Elevator.
> if (!(NorthElevator.running))
> ^
[snip!]

>class Elevator {
> boolean runnig = true;

^^^^^^
This is mispelled, should be running...

--Joe

___________________________________________________________________
Joseph A. Millar FTP Software, Inc.
Software Engineer Ph: (508) 684-6461 100 Brickstone Square
jmi...@ftp.com Fax:(508) 684-6992 Andover, MA 01810
http://www.ftp.com USA


Michael Lavallee

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to

>CAN YOU SUGGEST WHAT TO DO ?

>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++class Elevator {
> boolean runnig = true;


> void shutDown() {
> running = false;

If this is just a simple cut and paste, then you should note that initially you've
decleared a boolean variable called "runnig" and then later referred to it as
"running".

John Blomberg

unread,
Jul 3, 1996, 3:00:00 AM7/3/96
to ma...@patrol.i-way.co.uk

You have a typo. You wrote:

boolean runnig = true;

And it should read:

boolean running = true;

- jb

ma...@patrol.i-way.co.uk wrote:
Error: Hotel.java:4: Undefined variable: running
running = false;
^

WHEN I TRIED TO COMPILE THE TEXT BELOW I GOT THE ERRORS ABOVE


CAN YOU SUGGEST WHAT TO DO ?

class Elevator {

0 new messages