Created
March 24, 2017 15:56
-
-
Save RupGautam/2a9b43a73813ed7e6d5ff8bd853376e8 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 com.rupgautam.practice;/** | |
| * Created by RupGautam on 3/24/17. | |
| */ | |
| /** | |
| * Student Name: Rup Gautam | |
| * Student No: 3091289 | |
| */ | |
| public class Driver { | |
| public static void main(String[] args) { | |
| Subject math = new Subject("Math", "Mathematics"); | |
| Subject cs = new Subject("CS", "Computer Science"); | |
| Student jill = new Student("Jill", "Lee", 'F', true); | |
| Student sam = new Student("Samantha", "Jone", 'F', true); | |
| Student bob = new Student("Robert", "Smith", 'M', true); | |
| declareMajor(bob, math); | |
| System.out.println("Math majors = " + math.getMajors()); | |
| System.out.println(bob.getFirstName() +" "+ bob.getLastName()); | |
| } | |
| public static void declareMajor(Student s, Subject m) { | |
| if (s.getMajor() != null) { | |
| Subject oldMajor = s.getMajor(); | |
| oldMajor.removeMajor(s); | |
| } | |
| s.setMajor(m); | |
| m.addMajor(s); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment