/****** * @author G Towell * File: CSStudent.java * Created: Sep 6, 2019 * Modified: Sep 6, 2019 * Desc: class to implement CSStudent *******/ public class CSStudent extends Student { /** * true iff the student is a CS major **/ private boolean isMajor; /** * Make a CS student * @param name the name * @param id the student id * @param isMajor true if the student is a CS major **/ public CSStudent(String name, int id, boolean isMajor) { super(name, id); this.isMajor = isMajor; } /** * Accessor * @return true if student is a CS major **/ public boolean getIsMajor() {return isMajor;} /** * Setter * @param isMajor true iff the student is a CS major **/ public void setIsMajor(boolean isMajor) { this.isMajor=isMajor; } @Override public String toString() { // either of the following will work return super.toString() + " is " + (isMajor ? "" : "NOT") + " a CS major"; //return super.getName() + " " + super.getId() + " is " + (isMajor ? "" : "NOT") + " a CS major"; } }