File size: 1,435 Bytes
f4649dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Write a class according to the UML diagram below.

The functionality of the methods is not important (as long as the code compiles)
- it's enough that everything is defined according to the diagram.
https://ville.utu.fi/static_resources/jubery_utufi/Game_UML.png


Game
-name: String
-players: int


^
-
|
|
|
|
|


+Game(name: String, players: int)
+getName(): String
+setName(name: String): void
+getPlayers(): int
+setPlayers(players: int): void



=====================================

import java.util.Random;
import java.lang.reflect.Field;

public class Test {
    public static void main(String[] args) {
        

    }
}


// ADD
class Game {
  // attributes
  private String name;
  private int players;

  // constructor
  public Game(String name, int players){
      this.name = name;
      this.players = players;
  }

  
  public String getName() {
      return this.name;
  }
  public void setName(String name) {
      this.name = name;
  }
  
  public int getPlayers() {
      return this.players;
  }
  public void setPlayers(int players) {
      this.players = players;
  }

}




Testing the class Game...
Constructor found, game object created!

Checking attributes...
Attribute name found!
Attribute type: class java.lang.String
Attribute private: true

Attribute players found!
Attribute type: int
Attribute private: true

Checking methods...
getName works!
getPlayers works!

setName works!
setPlayers works!