質問するログイン新規登録

質問編集履歴

1

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

2021/01/13 10:56

投稿

gaju
gaju

スコア1

title CHANGED
File without changes
body CHANGED
@@ -9,14 +9,14 @@
9
9
  import java.util.Calendar;
10
10
 
11
11
  public abstract class Base {
12
- public static int tweetId = 0;
12
+ public int tweetId = 0;
13
- public static long datetime = 0;
13
+ public long datetime = 0;
14
- public static String userId = "";
14
+ public String userId = "";
15
15
 
16
16
  public Base(int tweetId,String userId) {
17
- Base.tweetId = tweetId;
17
+ this.tweetId = tweetId;
18
- Base.userId = userId;
18
+ this.userId = userId;
19
- Base.datetime = getNow();
19
+ this.datetime = getNow();
20
20
  }
21
21
  public static long getNow(){
22
22
  Calendar cl = Calendar.getInstance();
@@ -24,7 +24,7 @@
24
24
  return Long.parseLong(sdf.format(cl.getTime()));
25
25
  }
26
26
  public int getTweetId() {
27
- return this.tweetId;
27
+ return tweetId;
28
28
  }
29
29
  public abstract String getText();
30
30
 
@@ -42,7 +42,7 @@
42
42
  }
43
43
 
44
44
  public class Reply extends Tweet{
45
- private String target = Base.userId;
45
+ private String target = super.userId;
46
46
  public Reply(int tweetId,String userId,String text, Tweet target) {
47
47
  super(tweetId,userId,text);
48
48
  }