Hi please help I already got the wrong answer for a previous question I posted.
ID: 3703261 • Letter: H
Question
Hi please help I already got the wrong answer for a previous question I posted.
Valid studentIDs consist of an integer with sixdigits,i.e. in the range[100000,999999.]Modify the constructor of Student to throw an exception or an AssertionError when an attempt is made to construct a Student object where this speci?cation is violated.
Also,the sum of the weights of the assessments in an AssessmentScheme must always be 100. Add code to the AssessmentScheme class to enforce this speci?cation. My student.java class
public class Student {
private String studentID;
private String givenName;
private String familyName;
//Use given and family name because first name and last name
// might be confused with first and last student name
public Student(String newStudentId) {
studentID=newStudentId;
}
public Student (String newStudentId, String newGivenName, String newFamilyName) {
studentID= newStudentId;
givenName=newGivenName;
familyName=newFamilyName;
}
//Mutator methods
public void setGivenName(String givenName ) {
this.givenName=givenName;
}
public void setFamilyName(String familyName ) {
this.familyName=familyName;
}
// Accessor methods
public String description() {
return studentID + " " + givenName + " " + familyName;
}
public String getStudentId() {
return studentID;
}
}
AssessmentScheme.java class
import java.util.ArrayList;
public class AssessmentScheme {
private ArrayList<Assessment> assessmentArray = new ArrayList<>();
public void addAssessment(Assessment assessment){
assessmentArray.add(assessment);
}
public ArrayList getAssessmentScheme(){
return assessmentArray;
}
}
Explanation / Answer
Hi. please find the answer above.. i have given comments so that it is very easy for you to understand the flow. In case of any doubts, please ask in comments. If the answer helps you, please upvote. Thanks!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.