#!/bin/sh /*this shows what to run with, eg bash, ksh, sh */
notes:
* don't leave spaces where there should be spaces, things won't work.
A 2nd year Monash BITS student's struggle with FIT2034 Computer Programming 2 - Programming in Java. Armed with several IDEs, a range of textbooks and the interblag, she vows to learn the intricacies of programming, java, and everything.
public void test()
{
System.out.println("Enter ID");
int id = scanner.nextInt();
Employee employee = findEmployeeById(id);
displaySalary(employee);
}
public void displaySalary(Programmer programmer)
{
System.out.println(programmer.calculateSalary());
}
public void displaySalary(TeamLeader teamLeader)
{
System.out.println(teamLeader.calculateSalary());
} public void test()
{
System.out.println("Enter ID");
int id = scanner.nextInt();
Employee employee = findEmployeeById(id);
displaySalary(employee);
if (employee instanceof Programmer)
System.out.println ((Programmer)employee.calculateSalary());
elseif (employee instanceof TeamLeader)
System.out.println ((TeamLeader)employee.calculateSalary());
elseif (employee instanceof Cleaner)
System.out.println ((Cleaner)employee.calculateSalary());
}
public interface SalariedWorker
{
double calculateSalary;
}
public class TeamLeader implements SalariedWorker
{
public double calculateSalary()
{
return 100 * 100
}
}
public class Programmer implements SalariedWorker
{
public double calculateSalary()
{
return 50 * 50
}
} public void test()
{
System.out.println("Enter ID");
int id = scanner.nextInt();
Employee employee = findEmployeeById(id);
displaySalary(employee);
if (employee instanceof SalariedWorker)
displaySalary((SalariedWorker)employee);
else System.out.println("The employee is not a salaried worker");
} instanceof before, I was wondering how you check what type of subclass something is.

System.out.println("Hello World!"); joke. Or perhaps that's just lame.
public String toString()
{
SimpleDateFormat dF = new SimpleDateFormat("dd/MM/yyyy");
String theEnrolledDate = dF.format(enrolledDate);
return super.toString()
+ "/nEnrolled Date: " + theEnrolledDate
}
public Student(Date enrolledDate)
{
this.name = null;
this.id = idCounter++;
this.enrolledDate= enrolledDate;
}
Student s1 = new Student(new GregorianCalendar(2011, 0, 3).getTime());
SimpleDateFormat does not work when the date is null. It spits exceptions that don't make sense.....