Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PROGRAM MUST BE WRITTEN IN JAVA! -CLASS DESIGN //Student shell which must be filled in public class Student { String name; int studentID; int gradeLevel;
PROGRAM MUST BE WRITTEN IN JAVA!
-CLASS DESIGN
//Student shell which must be filled in
public class Student { String name; int studentID; int gradeLevel; double gpa; String[] schedule; //*****constuctors*************************************************** //Only 2 are listed here since the 3rd is up to you public Student() { } public Student(String n, int id, int l, double g, String[] s) { } //*****setter/getters*********************************************************************** public void setName(String n) { } public void setGradeLevel(int l) { } public void setGpa(double g) { } public void setSchedule(String[] s) { } public String getName() { } public int getStudentID() { } public int getGradeLevel() { } public double getGpa() { } public String[] getSchedule() { } //*****schedule modifiers****************************************** public boolean addClass(String s) { } public boolean deleteClass(String s) { } public String getPeriod(int p) { } //*****other public interface methods************************************** public String toString() { } public boolean equals(Object s) { } public void advance() { if(gradeLevel
//STUDENT ROSTER SHELL WHICH MUST BE FILLED IN public class StudentRoster { private Student[] roster; //an array of Student objects representing a class in school private int classSize; //the current number of students in the class (not the physical size of the array) //*************************************************************************************** //*****constructor*********************************************************************** //*************************************************************************************** //default constructor //size is the length of the array, i.e., the max size of the class...not the same as the variable classSize //precondition: the integer size is the size of the array. public StudentRoster(int size) { } //************************************************************************************** //*****public interface methods********************************************************* //************************************************************************************** //description: adds a Student to the classroom. If the student is able to be added, true is returned. //If the class is full, no student is added and false is returned //precondition:a valid Student object is received //postcondition:the Student will be added to roster in the first open space. If successful, true will be returned. // If there is no space in the array, the array remains unchanged and false is returned. public boolean add(Student s) { } //description: deletes a student from the classroom. If the student is not found in the class roster is unchanged and false is returned //precondition: A student id is received //postcondition: If the student is in the classroom it is deleted, all subsequent students in roster are shifted down 1 space // and true is returned. If the student is not in the classroom, roster is unchanged and false is returned. public boolean delete(int id) { } //description: returns the current number of students in the classroom //precondition:roster is not null //postcondition:the number of students currently in roster is returned, i.e., the logical size of the array as opposed to the physical size. public int getClassSize() { } //description: returns the student object whose student id matches the argument. If the student is not found, null is returned. //precondition: A student id is received //postcondition: A Student object is returned whose student id matches the argument. If the id is not found, null is returned. public Student getStudent(int id) { } //****************************************************************************** //*****Display options********************************************************** //****************************************************************************** //description: returns a String representation of a StudentRoster object //precondition: roster is not null //postcondition: a String representation of roster is returned in the form of a list of all the Student objects. public String toString() { } //description: returns a list of the names of the students in the classroom //precondition: roster is not null //postcondition: a list of the student names in the classroom is returned public String displayRoster() { } //description: returns a list of the students in the grade level as indicated by the parameter grade. If there are no students in requested level, // the phrase "no students in requested grade level" should be returned. //precondition: roster is not null and the argument grade is the requested grade level //postcondition: a list of all the students in the requested grade level is returned in the form name space student id (Smith, Will 123456) // the list should include the name, student id, grade level, and gpa of the students. Note that schedules are not included. public String displayGradeLevel(int grade) { } //description: returns the name and schedule of requested student as identified by the parameter id //precondition: roster is not null. //postcondition: the name and schedule of the requested student is returned. If the student is not found, the phrase // "student not found" is displayed. public String displaySchedule(int id) { } }student Define a Student class with the following specifications Fields String name //should be last name, first name int studentID double gpa . . int gradeLevel . char gender Methods Constructors o Must have 3 constructor methods, a default, a comprehensive, and another of your own design Setters/getters as appropriate .public void advance //advances the student to the next grade. Decide what to do for a senior public int graduate ) //returns the years left until graduation (seniors have 1 year) student has studied public void study (int hours) //displays a message saying how many hours the Write a test class that fully tests your class Define and test 2 classes, Student and StudentRoster. The classes are described below class Student Class fields name (in the form "lastname, firstname") grade level gpa Stringl schedule (7 classes) student id Methods 3 constructors (default, comprehensive, and 1 more of your choice) setters and getters, as appropriate equals() toString) schedule modifiers add a class to schedule given a String argument for the class boolean method that returns true if class is added and false otherwise. A class can be added if there is room in the array. The class should be added to the first "empty" index. delete a class from the schedule given a String argument for the class boolean method that returns true if class is deleted and false otherwise. If the requested class is not in the schedule, false is returned. If a class is deleted, the period should be reset to nul access a class by period Given an int argument for period, returns the name of the class. If there is no class that period, the word "unscheduled" is returned graduate, advance and study as previously discussed class StudentRoster Class fields Student[ roster int classSize Methods 1 default constructor receives an int argument to set the size of the roster array Accessor methods for class data . getter for classSize o access method for a student given student id. Should return a Student object, or null if student is not found add student adds a student to the classroom roster. Student is added to the end of the students already in the array . If roster is full, student is not added and roster is unchanged boolean method. Returns true if successful, false otherwise delete student . deletes a student from the roster, given an id argument boolean method-return true if deletion successful, false otherwise if the argument is not found in roster, roster is unchanged and false is returned . There shouldn't be gaps in roster after a deletion. Students are deleted in actuality by being written over by elements to the right as they are shifted left. Elements of roster should be shifted left after a deletion from the index of the deleted student and the logical size of the array should be decremented Ex. Assume student 123 is to be deleted from roster before 789, 456, 123, 321, 654, 987 after 789, 456, 321, 654, 987, 987) logical size: 6 logical size: 5 note: Notice that after sliding elements to left to "cover up" student 123, there are now 2 987s listed. That is why we need to keep track of the logical size (actual number of students) of roster. After decrementing the logical size on deletion, the effective size of the array is decreased Display type methods class roster returns a String representation of a list of all the student names in roster by grade level returns a String representation of all the student names in a given grade in list form student schedule returns a String representation of a given student's schedule headed by the name toString() returns a String representation of the full roster You may use the provided shells to help you define the classes. I have provided a small (incomplete) test class for StudentRoster. Note that there is further testing necessary to fully test StudentRoster
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started