• Post Reply Bookmark Topic Watch Topic
  • New Topic

output question  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm learning about abstract classes and I have to create an abstract auto class with make and price of a car, then two classes with a different type of car, and finally a main
to use them. Everything seems to work and when I run it it's fine but I do get an error on the main that I'm not using the local variable buick1 and acura1.
I'm curious because, while it runs for me, I want to make sure I'm doing it right and don't know of another way to do the output than this. I've put all four
classes but the issue is on the last one (5 and 7).

Thanks for any advice.







 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan Bishop wrote:I do get an error on the main that I'm not using the local variable buick1 and acura1.

All the message is saying is that you have created an object, assigned it to a reference and then you don't do anything with it.
Now this may be a valid thing to do, but the compiler is just warning you that it is unusual.
It's as though you've gone out and bought a car and then taken it immediately to the scrapyard.
Try putting
buick1.print();
on line 6 and the message should disappear.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you also show us the actual specification you were given for this program.
There are a few things that can be improved upon in your code, but I don't want to confuse you if the specification has told you to do things in a certain way.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't double‑space code. You need blank lines between methods, etc, but not after every line. I have been back and corrected the first two code blocks (but missed two lines) and you can see it is now actually easier to read.
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for taking so long to respond but thanks for the help. I can post the question if you want. I'm pretty much teaching myself on my own and it's a nightmare.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, please do post the question. The more we know the more we can help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!