Skip to content

Instantly share code, notes, and snippets.

@RupGautam
Created March 24, 2017 15:56
Show Gist options
  • Select an option

  • Save RupGautam/2a9b43a73813ed7e6d5ff8bd853376e8 to your computer and use it in GitHub Desktop.

Select an option

Save RupGautam/2a9b43a73813ed7e6d5ff8bd853376e8 to your computer and use it in GitHub Desktop.
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