Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- /**
- *
- */
- public class DeclareMajor
- {
- public static void main(String[] args){
- //ArrayList<String> cs = new ArrayList();
- Subject math = new Subject("Math","Mathematics");
- Subject cs = new Subject("CS","Computer Science");
- Student sam = new Student("Samantha","Jones",'F',true);
- Student rob = new Student("Robert","Smith",'M',true);
- Student jill = new Student("Jill","Lee",'F',true);
- // the majors
- sam.setMajor(cs);
- cs.addMajor(sam);
- rob.setMajor(cs);
- cs.addMajor(rob);
- jill.setMajor(math);
- math.addMajor(jill);
- System.out.println("Math majors = "+math.getMajors());
- System.out.println("cs= " +cs.getMajors());
- //int pos = cs.indexOf("Robert");
- //String removed = cs.remove(0);
- if (cs.contains(rob)) {
- cs.removeMajor(rob);
- rob.setMajor(math);
- cs.addMajor(rob);
- }
- //System.out.println(pos);
- System.out.println("get Rob's full name " + rob.getFullName());
- System.out.println("new Math majors = "+math.getMajors());
- System.out.println("new cs= " +cs.getMajors());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement