Hi pleasee help. I\'ve gotten the wrong answer many times. I wrote a programme t
ID: 3709081 • Letter: H
Question
Hi pleasee help. I've gotten the wrong answer many times. I wrote a programme that prompts the user to enter the marks, weightage and comments for every assessment the student has completed.Assesments are made up of assignments and exams. The marks class access the marks for every assessment a student has completed.However, I need to ensure that the mark for a piece of assessment must be between zero and the weight of that piece of assessment. I tried implementing it below but somehow it didn't work?Please explain why it didn't work
Marks.java
public class Mark extends Assessment {
private int mark;
private String comment;
public Mark(int newWeight, int newMark, String newComment) {
/*Changes here
setWeight(newWeight);
mark=getWeight();
if(mark < 0|| mark >newWeight) {
throw new IllegalArgumentException("Mark must be between 0 and weight of assessment. ");
}
*/
comment=newComment;
}
public String description(){
return "mark " + mark + "%" + " " + comment;
}
}
Assessment.java
/**
* The Class Assessment.
*/
public abstract class Assessment {
/** The weight. */
private int weight;
//setter
/**
* Sets the weight.
*
* @param weight the new weight
*/
public void setWeight(int weight ) {
this.weight=weight;
}
// getter
/**
* Gets the weight.
*
* @return the weight
*/
public int getWeight() {
return weight;
}
/**
* Description.
*
* @return the string
*/
public abstract String description();
}