質問編集履歴

1

Baseクラスのフィールドのstaticを除去 BaseインスタンスのBase.~をthis.~へ変更

2021/01/13 10:56

投稿

gaju
gaju

スコア1

test CHANGED
File without changes
test CHANGED
@@ -20,21 +20,21 @@
20
20
 
21
21
  public abstract class Base {
22
22
 
23
- public static int tweetId = 0;
23
+ public int tweetId = 0;
24
24
 
25
- public static long datetime = 0;
25
+ public long datetime = 0;
26
26
 
27
- public static String userId = "";
27
+ public String userId = "";
28
28
 
29
29
 
30
30
 
31
31
  public Base(int tweetId,String userId) {
32
32
 
33
- Base.tweetId = tweetId;
33
+ this.tweetId = tweetId;
34
34
 
35
- Base.userId = userId;
35
+ this.userId = userId;
36
36
 
37
- Base.datetime = getNow();
37
+ this.datetime = getNow();
38
38
 
39
39
  }
40
40
 
@@ -50,7 +50,7 @@
50
50
 
51
51
  public int getTweetId() {
52
52
 
53
- return this.tweetId;
53
+ return tweetId;
54
54
 
55
55
  }
56
56
 
@@ -86,7 +86,7 @@
86
86
 
87
87
  public class Reply extends Tweet{
88
88
 
89
- private String target = Base.userId;
89
+ private String target = super.userId;
90
90
 
91
91
  public Reply(int tweetId,String userId,String text, Tweet target) {
92
92