/**
* models the player in a game of RPS
*/
public class RockpaPaperScissors {
private int playerChoice; //ROCK = 1, PAPER = 2, SCISSORS = 3
//constructor
public Player() {
playerChoice = 1;
}
public void setChoice(int newChoice){
playerChoice = newChoice;
}
public int getChoice() {
return(Player);
}
}
What wrong ?
It tells me
1 error found:
File: C:\Documents and Settings\Dulitha.DULITHA-668FD42\RockpaP... [line: 10]
Error: C:\Documents and Settings\Dulitha.DULITHA-668FD42\RockpaP... invalid method declaration; return type required
Java compiler error ?
If you declare constructor, it should have the same name as your class:
public RockpaPaperScissors() {
playerChoice = 1;
}
also, your getChoice() method doesn't make any sense. Perhaps you meant this:
public int getChoice() {
return playerChoice;
}
Reply:your constructor should have the same name as of class like
public RockpaPaperScissors() {
//youe code here
}
and the method
public Player() {
playerChoice = 1;
}
should be like
public int Player() {
playerChoice = 1;
}
try with the changes mentioned. it'll work for sure
survey questions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment