Write the implementation (.cpp file) of the ContestResult class from the previous exercise. Again, the class contains: 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 function called setWinner that has one parameter, whose value it assigns to the instance variable winner. A function called setSecondPlace that has one parameter, whose value it assigns to the instance variable secondPlace. A function called setThirdPlace that has one parameter, whose value it assigns to the instance variable thirdPlace. A function called getWinner that has no parameters and that returns the value of the instance variable winner. A function called getSecondPlace that has no parameters and that returns the value of the instance variable secondPlace. A function called getThirdPlace that has no parameters and that returns the value of the instance variable thirdPlace.

Write the implementation (.cpp file) of the ContestResult class from the previous exercise. Again, the class contains: 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 function called setWinner that has one parameter, whose value  it assigns to the instance variable winner. A function called setSecondPlace that has one parameter, whose value it assigns to the instance variable secondPlace. A function called setThirdPlace that has one parameter, whose value it assigns to the instance variable thirdPlace. A function called getWinner that has no parameters and that returns the value of the instance variable winner. A function called getSecondPlace that has no parameters and that returns the value of the instance variable secondPlace. A function called getThirdPlace that has no parameters and that returns the value of the instance variable thirdPlace.

LANGUAGE: C++

CHALLENGE:

Write the implementation (.cpp file) of the ContestResult class from the previous exercise. Again, the class contains: 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 function called setWinner that has one parameter, whose value it assigns to the instance variable winner. A function called setSecondPlace that has one parameter, whose value it assigns to the instance variable secondPlace. A function called setThirdPlace that has one parameter, whose value it assigns to the instance variable thirdPlace. A function called getWinner that has no parameters and that returns the value of the instance variable winner. A function called getSecondPlace that has no parameters and that returns the value of the instance variable secondPlace. A function called getThirdPlace that has no parameters and that returns the value of the instance variable thirdPlace.

SOLUTION:


void ContestResult::setWinner (string aWinner){
    winner = aWinner;
}

void ContestResult::setSecondPlace (string fSecondPlace){
    secondPlace = fSecondPlace;
}

void ContestResult::setThirdPlace (string fThirdPlace){
    thirdPlace = fThirdPlace;
}

string ContestResult::getWinner (){
    return winner;
}

string ContestResult::getSecondPlace(){
    return secondPlace;
}

string ContestResult::getThirdPlace(){
    return thirdPlace;
}

Add comment