Created
September 1, 2017 17:41
-
-
Save khayyamsaleem/5c2412915fc2f58f6997046cd240d35a 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
package rc1; | |
public class Course { | |
String name; | |
int cap; | |
String dept; | |
Professor prof; | |
public Course(String name, int cap, String dept, Professor prof) { | |
this.name = name; | |
this.cap = cap; | |
this.dept = dept; | |
this.prof = prof; | |
} | |
} |
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
package rc1; | |
public class Person { | |
String name; | |
int age; | |
public Person(String name, int age) { | |
this.name = name; | |
this.age = age; | |
} | |
} |
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
package rc1; | |
public class Professor extends Person{ | |
String dept; | |
public Professor(String name, int age, String dept) { | |
super(name, age); | |
this.dept = dept; | |
} | |
} |
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
package rc1; | |
public class Student extends Person{ | |
private float gpa; | |
private int creds; | |
public Student(String name, int age, float gpa, int creds) { | |
super(name, age); | |
this.gpa = gpa; | |
this.setCreds(creds); | |
} | |
public float getGPA() { | |
return this.gpa; | |
} | |
public void setGPA(float gpa) { | |
this.gpa = gpa; | |
} | |
public int getCreds() { | |
return creds; | |
} | |
public void setCreds(int creds) { | |
this.creds = creds; | |
} | |
} |
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
package rc1; | |
@SuppressWarnings("unused") | |
public class University { | |
private final int SIZE; | |
private Person[] faculty; | |
private Student[] students; | |
private Course[] courses; | |
private int facInd = 0; | |
private int studInd = 0; | |
private int courseInd = 0; | |
public University(int size) { | |
this.SIZE = size; | |
this.faculty = new Person[10]; | |
this.students = new Student[10]; | |
this.courses = new Course[4]; | |
} | |
public void addCourse(Course c) { | |
if(courseInd > 3) { | |
System.out.println("COURSES LIST ALREADY FULL!"); | |
return; | |
} | |
this.courses[courseInd] = c; | |
courseInd++; | |
System.out.println("Added" + c.name); | |
} | |
public static void main(String[] args) { | |
University stevens = new University(20); | |
Professor k = new Professor("Khayyam", 19, "CS"); | |
for(int i = 0; i < 5; i++) { | |
stevens.addCourse(new Course("CS284", 17, "CS", k)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment