Created
March 8, 2013 21:16
-
-
Save mohnish/5119939 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
| class Management { | |
| static listOfStudents = new ArrayList<Student>(); | |
| public static void main(String[] args) { | |
| School wku = new School("Western Kentucky University"); | |
| Student macha = new Student("macha", 10, 8, wku); | |
| Student mt = new Student("mt", 10, 8, wku); | |
| addStudent(macha); | |
| addStudent(mt); | |
| System.out.println("Total number of students: " + listOfStudents.size()); | |
| } | |
| static void addStudent(Student student) { | |
| listOfStudents.add(student); | |
| } | |
| } |
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
| class School { | |
| String name; | |
| public School(String name) { | |
| this.name = name; | |
| } | |
| } |
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
| class Student { | |
| String name; | |
| int rollNumber; | |
| int standard; | |
| School school; | |
| public Student(String name, int rollNumber, int standard, School school) { | |
| this.name = name; | |
| this.rollNumber = rollNumber; | |
| this.standard = standard; | |
| this.school = school; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment