我正在为我的学校项目制作一个猜谜游戏,但我对Android Studio和Java都很陌生.
目前我的代码看起来像这样:
public class MainActivity extends AppCompatActivity {
public int score = 0;
int random = random();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button correct = (Button) findViewById(R.id.correct);
Button other = (Button) findViewById(R.id.other);
Button newGame = (Button) findViewById(R.id.newGame);
TextView words = (TextView) findViewById(R.id.words);
}
public Integer random (){
int random = (int )(Math.random() * 5);
return random;
}
private String list[] =
{"Dog", "Cat", "Mouse", "Elephant", "Rat", "Parrot"};
public void clickedButton(View view) {
TextView words = (TextView) …Run Code Online (Sandbox Code Playgroud) I have made my first tic tac toe game on android, but I have found a bug and I dont know how to fix it.
When player1 wins with last turn in certain combinations like bottom row horizontal or first vertical row then it pops - It is a draw - when there is winner.
Here I define my variables.
public class MainActivity extends AppCompatActivity {
// 0 yellow ; 1 red;
int activePlayer = 0;
boolean gameIsActive = true; …Run Code Online (Sandbox Code Playgroud)