• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Total newbie and I am lost so far.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two programs and I am trying to get them both to compile, one does, the other gives me errors and I not sure why.

Program 1




Program 2



I am getting this error message for lab 8

----jGRASP exec: javac -g Lab08.java
Lab08.java:11: int cannot be dereferenced
while(!arg.nextToABeeper())
^
Lab08.java:13: int cannot be dereferenced
if(arg.frontIsClear())
^
Lab08.java:15: int cannot be dereferenced
arg.move();
^
Lab08.java:19: int cannot be dereferenced
arg.jumpRight();
^
Lab08.java:34: cannot find symbol
symbol : class Racer
location: class Lab08
race( new Racer(1) );
^
Lab08.java:38: cannot find symbol
symbol : class SteepleChaseRacer
location: class Lab08


As I said I am a total newbie and I would really appreciate some help here.

Marc
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marc Guilbault wrote:
Lab08.java:11: int cannot be dereferenced
while(!arg.nextToABeeper())
^




The arg variable is of a primative int variable type. It doesn't have a nextToABeeper() method.

Henry
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

You should always use code tags; so you can see how they work and how much of an improvement they make, I have added them to your post.
There is something I don't like about those if-elses in the main method. I am not quite sure how to sort it out.
There is also something wrong with the race() method. Shouldn't that be an instance method of the Racer class. And you have got confusion; you are writing race() in one place and Racer() elsewhere. The compiler will surely complain about that.
 
Marc Guilbault
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for the code tag information. I will do my best to ensure I do this properly. So we have 4 small pieces of code and I am stumped.

Here they are:

BoxTop Racer




Racer



Lab8


SteepleChase





The error I am getting is:

Lab08.java:38: race(Racer) in Lab08 cannot be applied to (SteepleChaseRacer)
race( new SteepleChaseRacer(1) );
^
Lab08.java:42: race(Racer) in Lab08 cannot be applied to (BoxTopRacer)
race( new BoxTopRacer(1) );
^
2 errors
1 warning

Any help would be most appreciated and my sincere thanks in advance. I am so new at this and I am struggling to understand what is wrong.

Marc
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marc Guilbault wrote:
The error I am getting is:

Lab08.java:38: race(Racer) in Lab08 cannot be applied to (SteepleChaseRacer)
race( new SteepleChaseRacer(1) );
^

Any help would be most appreciated and my sincere thanks in advance. I am so new at this and I am struggling to understand what is wrong.



The error message is clear. The race() method takes a single Racer object as a parameter. You passed it a SteepleChaseRacer object, and SteepleChaseRacer is not a Racer. Perhaps you meant to have the SteepleChaseRace class subclass the Racer class?

Henry
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic