From f9244082a2b3b8a75c82778c7ee395cdfa08421b Mon Sep 17 00:00:00 2001 From: Dominik Krenn Date: Mon, 15 Sep 2025 15:35:33 +0200 Subject: [PATCH] Refactor Main class to improve structure and remove unused code --- Main.java | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/Main.java b/Main.java index d5e0b6e..2b56fa9 100644 --- a/Main.java +++ b/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(); } }