228k views
25 votes
Write the complete class declaration for the class StudentReserve. Include all necessary instance variables and implementations of its constructor and method(s). The constructor should take a parameter that indicates the number of days in advance that this pass is being reserved. The toString method should include a notation that a student ID is required for this pass. A StudentReserve pass costs half of what that Reserve pass would normally cost. If the pricing scheme for Reserve passes changes, the StudentReserve price should continue to be computed correctly with no code modifications to the StudentReserve class.

1 Answer

1 vote

Answer:

Step-by-step explanation:

There is a lot of needed information that is missing in this question including all of the instance variables, what methods are required and what they need to do. The following code is a rough estimate of some of the basic methods and instance variables that are needed based on the information provided in the question.

package sample;

public class StudentReserve {

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

String name, id;

int studentReservePrice, reservedDays;

public void StudentReserve(int numOfDays) {

this.reservedDays = numOfDays;

}

public String toString() {

System.out.println("A Student ID is required");

return null;

}

public int getStudentReservePrice(int regularReservePrice) {

this.studentReservePrice = regularReservePrice / 2;

return studentReservePrice;

}

}

User Johannchopin
by
4.7k points