Refactor Main class to improve structure and remove unused code
This commit is contained in:
parent
6586e59959
commit
f9244082a2
47
Main.java
47
Main.java
@ -1,19 +1,42 @@
|
||||
import java.sql.SQLException;
|
||||
|
||||
import src.models.UserModel;
|
||||
import src.squirrel.Database;
|
||||
import src.squirrel.ModelManager;
|
||||
import quick.Interface;
|
||||
import squirrel.Database;
|
||||
import squirrel.ModelManager;
|
||||
import interfaces.Index;
|
||||
import interfaces.Login;
|
||||
import java.sql.Connection;
|
||||
import squirrel.LocalStorage;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws SQLException {
|
||||
public static void main(String[] args) {
|
||||
ModelManager.initializeModels();
|
||||
Database.migrate = conn -> src.Migration.run(conn);
|
||||
Database.getConnection();
|
||||
Connection conn = Database.getConnection();
|
||||
Migration.run(conn);
|
||||
|
||||
UserModel userModel = ModelManager.get(UserModel.class);
|
||||
UserModel user = userModel.register("Jack", "jack@example.com", "1234");
|
||||
System.out.println("Registered user: " + user);
|
||||
Interface app = new Interface(Login.class);
|
||||
app.registerView(Index.class);
|
||||
app.registerView(Login.class);
|
||||
|
||||
Database.close();
|
||||
class Point {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z = 0;
|
||||
public String name = "origin";
|
||||
|
||||
public Point(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
Point p = new Point(3, 4);
|
||||
System.out.println("Point: (" + p.x + ", " + p.y + ", " + p.z + ", " + p.name + ")");
|
||||
|
||||
LocalStorage storage = new LocalStorage();
|
||||
storage.save("point1", p);
|
||||
|
||||
Point loaded = storage.load("point1", Point.class);
|
||||
System.out.println("Loaded Point: (" + loaded.x + ", " + loaded.y + ", " + loaded.z + ", " + loaded.name + ")");
|
||||
|
||||
storage.flush();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user