Loading src/model/Account.java +7 −0 Changes for src/model/Account.java: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package model; import com.alibaba.fastjson2.JSON; import network.Client; import view.Theme; import java.io.IOException; import java.nio.file.Files; Loading Loading @@ -35,6 +36,8 @@ public class Account { private String name; //名称 public Theme theme; /** * 本机账号对象 */ Loading @@ -45,6 +48,9 @@ public class Account { * @throws IllegalArgumentException 非法名称异常,可以直接拿异常的message输出到GUI */ public Account(String name) throws IllegalArgumentException { this(name, Theme.DEFAULT); } public Account(String name, Theme theme) throws IllegalArgumentException { if (name == null || name.length() == 0) { throw new IllegalArgumentException("名称不能为空"); } Loading @@ -56,6 +62,7 @@ public class Account { } this.name = name; this.uuid = UUID.randomUUID().toString(); this.theme = theme; } public String getName() { Loading src/view/Theme.java 0 → 100644 +10 −0 Changes for src/view/Theme.java: 10 added lines, 0 removed lines. Original line number Diff line number Diff line package view; public enum Theme { DEFAULT("img"), STYLE_2("img"), STYLE_3("img"); public final String imgDir; Theme(String imgDir) { this.imgDir = imgDir; } } test/GameJSONTest.java +2 −0 Changes for test/GameJSONTest.java: 2 added lines, 0 removed lines. Original line number Diff line number Diff line import com.alibaba.fastjson2.JSON; import model.Account; import model.game.Game; import model.dataType.GameType; public class GameJSONTest { public static void main(String[] args) { System.out.println(JSON.toJSONString(new Game(GameType.LOCAL_2P))); System.out.println(JSON.toJSONString(Account.SELF)); } } Loading
src/model/Account.java +7 −0 Changes for src/model/Account.java: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package model; import com.alibaba.fastjson2.JSON; import network.Client; import view.Theme; import java.io.IOException; import java.nio.file.Files; Loading Loading @@ -35,6 +36,8 @@ public class Account { private String name; //名称 public Theme theme; /** * 本机账号对象 */ Loading @@ -45,6 +48,9 @@ public class Account { * @throws IllegalArgumentException 非法名称异常,可以直接拿异常的message输出到GUI */ public Account(String name) throws IllegalArgumentException { this(name, Theme.DEFAULT); } public Account(String name, Theme theme) throws IllegalArgumentException { if (name == null || name.length() == 0) { throw new IllegalArgumentException("名称不能为空"); } Loading @@ -56,6 +62,7 @@ public class Account { } this.name = name; this.uuid = UUID.randomUUID().toString(); this.theme = theme; } public String getName() { Loading
src/view/Theme.java 0 → 100644 +10 −0 Changes for src/view/Theme.java: 10 added lines, 0 removed lines. Original line number Diff line number Diff line package view; public enum Theme { DEFAULT("img"), STYLE_2("img"), STYLE_3("img"); public final String imgDir; Theme(String imgDir) { this.imgDir = imgDir; } }
test/GameJSONTest.java +2 −0 Changes for test/GameJSONTest.java: 2 added lines, 0 removed lines. Original line number Diff line number Diff line import com.alibaba.fastjson2.JSON; import model.Account; import model.game.Game; import model.dataType.GameType; public class GameJSONTest { public static void main(String[] args) { System.out.println(JSON.toJSONString(new Game(GameType.LOCAL_2P))); System.out.println(JSON.toJSONString(Account.SELF)); } }