Skip to content

Instantly share code, notes, and snippets.

@nshiba
Created May 1, 2018 00:59
Show Gist options
  • Save nshiba/d4da2b98b7718362349fe1e4e18dd165 to your computer and use it in GitHub Desktop.
Save nshiba/d4da2b98b7718362349fe1e4e18dd165 to your computer and use it in GitHub Desktop.
public class Game {
private GameCoreListener listener = null;
...
Game(Subcode subcode, GameCoreListener listener) {
select = 0;
this.subcode = subcode;
this.stage = "outofrange";
//database = new Database(this);
// リスナーセット
this.listener = listener;
}
//スタート
void GameStart() {
//正解のドアとダミーのドアの決定
correct = 1 + new java.util.Random().nextInt(100);
do {
dummy = 1 + new java.util.Random().nextInt(100);
}
while (correct == dummy);
// GameCoreActivity.textChange("test", "gamestart", "textView");
listener.textChange("test", "gamestart", "textView");
}
...
}
public class GameCoreActivity extends AppCompatActivity implements GameCoreListener {
...
Database database;
Game game = new Game(subcode, this);
Door[] door = new Door[100];
//画面テキストを変更するためにテキストビューを指定
TextView game_core;
...
/*
//画面表示の変更
public void textChange(String name, String input, String output) {
TextView name = findViewById(R.id.output);
name.setText(R.string.input);
}
*/
@Override
public void textChange(String name, String input, String output) {
TextView name = findViewById(R.id.output);
name.setText(R.string.input);
}
}
interface GameCoreListener {
void textChange(String name, String code, String target);
}
//処理の移譲
interface Subcode {
//ボタンを非表示にする(テスト用)
void disableButton();
//プレイヤーに選択されているドアのidを返す関数
int idSearch();
void writeing(String score);
void reading();
void textChange(String name, String input, String output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment