CSC/ECE 517 Fall 2007/wiki1 6 b2: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
== Java solution ==
== Java solution ==
<pre>
Staff.java
Staff.java
public interface staff {
public interface staff {
Line 45: Line 46:


}
}
</pre>

Revision as of 21:34, 14 September 2007

Java solution

Staff.java
public interface staff {
	void saySta();
}

Student.java
public interface student {
	void sayStu();
}
WorkStudy.java
public class WorkStudy implements staff, student{
	private String name;
	WorkStudy(String name){
		this.name=name;
	}
	
	public void saySta(){
		System.out.println(name+" is working here!");	
	}
	
	public void sayStu(){
		System.out.println(name+" is studying here!");
	}
	
	public void say(){
		saySta();
		sayStu();
		System.out.println("So, "+name+" is work-study student here!");
	}
}

mainclass.java
public class mainclass {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		WorkStudy j;
		j=new WorkStudy("Ying");
		j.say();
	}

}