King_Weaver
Gawd
- Joined
- Nov 26, 2006
- Messages
- 620
Ok so for a hw assignment thats due tomorrow I had to create a class that creates objects with certain attributes and then a test class that creates five objects and set values for them and then prints out the data based on a tostring method in the first class. Anyway the two classes are below, the only problem is when I try to run the testclass in netbeans the output looks like this
init:
deps-jar:
Compiling 1 source file to K:\Weaver_Joseph_Cop2250_U03_Spring2008\Projects\Project 5\build\classes
compile-single:
run-single:
BUILD SUCCESSFUL (total time: 0 seconds)
as you can see the class doesn't produce any ouput like it should... I even put in a test println and it doesnt show up either
init:
deps-jar:
Compiling 1 source file to K:\Weaver_Joseph_Cop2250_U03_Spring2008\Projects\Project 5\build\classes
compile-single:
run-single:
BUILD SUCCESSFUL (total time: 0 seconds)
as you can see the class doesn't produce any ouput like it should... I even put in a test println and it doesnt show up either
Code:
package project5;
import java.text.NumberFormat;
public class HourlyEmployee {
private String name;
private String position;
private double rate;
private double hours;
private double pay;
public HourlyEmployee(String aName, String aPosition, double aRate) {
name = aName;
position= aPosition;
rate = aRate;
}
public double getpay(){
pay = hours * rate;
if (hours > 40)
pay += (hours - 40) * rate *1.5;
return pay;
}
public void work(double time){
hours += time;
}
public void setaRaise(double inc){
rate+= inc;
}
public boolean equals(String aName,String aPosition,double aRate) {
if (name==aName && position == aPosition && rate == aRate){
System.out.println("true");
return true;
}
else System.out.println("false");
return false;
}
public String toString(){
NumberFormat nf = NumberFormat.getCurrencyInstance();
return ("\n=======================" + "\nEmployee:" + name + "\nPosition:" + position
+ "\nPay Rate:" +rate + "\nHours Worked:" + hours + "\nHours" + nf.format(pay) );
}
}
Code:
import project5.HourlyEmployee;
public class HourlyEmployeeTest {
public static void main(String arguments[]) {
System.out.println("TESTING");
//create two HourlyEmployee objects
HourlyEmployee emp1 = new HourlyEmployee("Joseph Weaver","Ruler of the Known Universe",300);
HourlyEmployee emp2 = new HourlyEmployee("Joseph Weaver","Ruler of the Known Universe",300);
HourlyEmployee emp3 = new HourlyEmployee("Clone of Joseph Weaver","Personal bodyguard and double",8);
HourlyEmployee emp4 = new HourlyEmployee("Andrew","Teacher",50);
HourlyEmployee emp5 = new HourlyEmployee("Batman","Crime Fighter",0);
emp1.work(38);
emp2.work(168);
emp3.work(20);
emp4.work(48);
emp5.work(84);
System.out.println(emp1);
System.out.println(emp2);
System.out.println(emp3);
System.out.println(emp4);
System.out.println(emp5);
emp1.setaRaise(1);
emp2.setaRaise(1);
emp3.setaRaise(1);
emp4.setaRaise(1);
emp5.setaRaise(1);
emp1.work(38);
emp2.work(168);
emp3.work(20);
emp4.work(48);
emp5.work(84);
System.out.println(emp1);
System.out.println(emp2);
System.out.println(emp3);
System.out.println(emp4);
System.out.println(emp5);
}
}