Created
November 1, 2017 20:55
-
-
Save pzp1997/2dc2c1d06c41193b224882925d145776 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
PennPerson p = new Professor(); | |
p.sleep(6); | |
Undergraduate u = new Undergraduate(); | |
// p.teach("CIS 120"); | |
} | |
} | |
public interface PennPerson { | |
public void sleep(int hours); | |
} | |
public class Professor implements PennPerson { | |
public void sleep(int hours) { | |
System.out.println(Integer.toString(hours * 2) + "hours"); | |
} | |
public void teach(String course) { | |
System.out.println("teaching " + course); | |
} | |
} | |
public abstract class Student implements PennPerson { | |
private String[] coursesEnrolled; | |
public Student() { | |
coursesEnrolled = new String[5]; | |
} | |
public void sleep(int hours) { | |
System.out.println(Integer.toString(hours / 2) + "hours"); | |
} | |
public void abstract enrolls(String course, int n); | |
} | |
public class Undergraduate extends Student { | |
public Undergraduate() { | |
super(); | |
} | |
public void enrolls(String course, int n) { | |
coursesEnrolled[n] = course; | |
} | |
} | |
public class Graduate extends Student { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment