| Author |
First Java Program
|
Matt Dogg
Greenhorn
Joined: Mar 01, 2006
Posts: 2
|
|
I am trying to write a program that displays the characteristics of a lightbulb, changes and displays the color of the lightbulb, changes and displays wattage of lightbulb, and turns the lightbulb on if it is off. When I compile I am getting four errors. Can someone give me a nudge in the right direction to fix my errors? Thanks. [ EFH: Added some [ CODE][ /CODE] tags to preserve formatting ] [ March 01, 2006: Message edited by: Ernest Friedman-Hill ]
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 2686
|
|
|
Do you want to tell us what the errors are and which lines they are on ?
|
Joanne
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 23395
|
|
Hi, Welcome to JavaRanch! I can see three errors; there may be more, or one of the messages may be a red herring, which happens some times. 1) on the very first line, you named the class lightbuld, but then later use the correct spelling. 2) In "displaylightbulb", you forgot a "+" between the first string and 'color' in the first println call. 3) Also in the same routine, there's an open brace after the "else", but no matching close brace for it. For future references: when posting code that won't compile, it's helpful to post the error messages too; it makes it easier on people who'd like to help!
|
[Jess in Action][AskingGoodQuestions]
|
 |
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 799
|
|
ok first of all, "m.wattage", i didnt see the method to set that in your code or m.Color for that matter... yeah you have methods that modify these, but none that set them. you need to make something along those lines, i hope this helped a little bit
|
You down with OOP? Yeah you know me!
|
 |
Keith Lynn
Ranch Hand
Joined: Feb 07, 2005
Posts: 2306
|
|
|
There is also a problem in the String concatenation.
|
 |
Matt Dogg
Greenhorn
Joined: Mar 01, 2006
Posts: 2
|
|
|
That helped a bunch, thanks a lot!!!
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
For future reference, please post the compiler error messages you get. This will help us more easily answer your questions and suggest solutions. Layne
|
Java API Documentation
The Java Tutorial
|
 |
 |
|
|
subject: First Java Program
|
|
|