You are on page 1of 2

package pack1;

class Job
{
String title;
double salary;
Job(title,salary)
{
this.title = title;
this.salary = salary;
}
}
------
class Employee
{
private int index;
Job x[];

Employee(Job x[])
{
this.x = x;
}
boolean hasNext()
{
return index < x.length;
}

Job nextJob()
{
return x[index++]
}
}
-----
class Employee
{
private int index;
Job x[];

Employee(Job x[])
{
this.x = x;
}
boolean hasNext()
{
return index < x.length;
}

Job nextJob()
{
return x[index++]
}
print()
{
while(nextJob())
{
Job j = hasnext();
System.out.println(j.title + j.salary);
}
}
}
-----
class Manager1
{
public static void main(String atgs[])
{
Job j1 = new job("Software",50000.0);
Job j2 = new job("hardware",50000.0);
Job j3 = new job("ware",50000.0);

Job x[] = {j1,j2,j3}

Employee emp = new Employee(x);

print(emp);
print(emp);
print(emp);
}
public static void print(Employee emp)
{
while(emp.hasNext())
{
Job j1 = emp.nextJob();
System.out.println(j1.title + j1.salary);
}
}
}
--------------
class Manager1a
{
public static void main(String atgs[])
{ Job x[];
Job x[1] = new job("Software",50000.0);
Job x[2] = new job("hardware",50000.0);
Job x[3] = new job("ware",50000.0);



Employee emp = new Employee(x);

emp.print();

}

--------------

You might also like