質問編集履歴

1

付けたし

2015/08/03 06:45

投稿

daichanman123
daichanman123

スコア32

test CHANGED
File without changes
test CHANGED
@@ -23,3 +23,79 @@
23
23
  よかったらサンプルコードを載せていただきたいです。
24
24
 
25
25
  よろしくお願いいたします。
26
+
27
+
28
+
29
+
30
+
31
+ public class Player {
32
+
33
+
34
+
35
+ String name;
36
+
37
+ int hand;
38
+
39
+
40
+
41
+ static final int gu = 0, tyoki = 1, pa = 2;
42
+
43
+
44
+
45
+
46
+
47
+ //コンストラクタ
48
+
49
+ public Player(String name){
50
+
51
+
52
+
53
+ this.name = name;
54
+
55
+ }
56
+
57
+
58
+
59
+
60
+
61
+ //手を出すメソッド
62
+
63
+ public int playhand(){
64
+
65
+
66
+
67
+ Random rnd = new Random();
68
+
69
+ int run = rnd.nextInt(3);
70
+
71
+
72
+
73
+ if(run == 0){
74
+
75
+ hand = gu;
76
+
77
+ }
78
+
79
+ else if(run == 1){
80
+
81
+ hand = tyoki;
82
+
83
+ }
84
+
85
+ else{
86
+
87
+ hand = pa;
88
+
89
+ }
90
+
91
+ System.out.print(hand);
92
+
93
+ return hand;
94
+
95
+ }
96
+
97
+ }
98
+
99
+
100
+
101
+ playerクラスはこんな感じかなと思っています。