I don't mind reading and figuring stuff out, but I don't even know where to look.
public class Employee
name = "unknown";
salary = 0;
public class EmployeeTester
public EmployeeTester ()
name = "Robert Samberg";
salary = 50000;
public void newSalary(double amount)
double newSalary = salary + (salary/20.0);
salary = newSalary;
Can someone tell me what if anything is right with this code?
[ January 28, 2006: Message edited by: Rob Samberg ]
The Java compiler won't let you do this. If you have two constructors they must have different signitures meaning, the must take a different number or type of parameters. These two constructors should be combined to give you your default constructor:
As for this bit:
you should avoid putting a main() method into this class at all, leave that for your EmployeeTester class. Instead you should write getter and setter methods to access your Employee object's name and salary i.e. getName(), setName(), getSalary(), setSalary(). These methods can be called by the main() method in your EmployeeTester class to mutate and access information regarding any Employee object. Hope this can get you started.
Originally posted by Rob Samberg:
... If you can think of anything else that might help, even if it's just general Java stuff for a beginner, I'd appreciate it...
Use Code Tags to preserve your formatting.
Originally posted by Gerardo Tasistro:
Are you guys using an IDE? Creating getters and setters are catchy the first two times after that it is just tiresome. IDE's will help a lot with that.
IMO for a beginner, it is necessary to write getters and setters by hand. No IDE, just a text editor. In much the same way that many simple arithmetic problems can be solved on a calculator, it is a lot more educational to learn to do it yourself first. You know "Give a man a fish..."
[ January 28, 2006: Message edited by: Garrett Rowe ]