121k views
3 votes
Write the definition of a class ContestResult containing: An instance variable winner of type String, initialized to the empty String. An instance variable secondPlace of type String, initialized to the empty String. An instance variable thirdPlace of type String, initialized to the empty String.

A. A method called setWinner that has one parameter, whose value it assigns to the instance variable winner.
B. A method called setSecondPlace that has one parameter, whose value it assigns to the instance variable secondPlace.
C. A method called setThirdPlace that has one parameter, whose value it assigns to the instance variable thirdPlace.
D. A method called getWinner that has no parameters and that returns the value of the instance variable winner.
E. A method called getSecondPlace that has no parameters and that returns the value of the instance variable secondPlace. A method called getThirdPlace that has no parameters and that returns the value of the instance variable thirdPlace. No constructor need be defined.

User Zachbugay
by
5.1k points

1 Answer

3 votes

Answer:

I will use JAVA to answer the question.

The class ContestResult could be:

public class ContestResult {

String winner;

String secondPlace;

String thirdPlace;

public void setWinner(String e){ //set position of winner.

this.winner = e;

}

public String getWinner(){ //get position winner

return this.winner;

}

public void setSecondPlace(String e){ //set position of second place.

this.secondPlace = e;

}

public String getSecondPlace(){ //get second place

return this.secondPlace;

}

public void setThirdPosition(String e){ //set position of third place.

this.thirdPlace = e;

}

public String getThirdPlace(){ //get third place

return this.thirdPosition;

}

}

User Nevedha Ayyanar
by
5.0k points