Hi there! I'm doing a small project for the University, where the idea is to do a game using
Java Swing applying the corresponding design
patterns (like facade, singleton, factory, composite, observer, proxy, template, etc.).
I've just started and have a couple of questions:
1. Regarding facade and detachement between the UI and my UsersSystem (gets in charge of validating the username/pass and has the users/admin/gamer classes).
There are two roles of users: admins and gamers. Their login screen is identical.
Package UI
Class FrameLogin
-UserRole loginUserRole //being the same login screen, I set this role when starting the Frame, so that I can pass it to the Facade
Package Facade
Class Facade
+User Login(User, UserRole)
Package UsersSystem
Class UsersSystem
+User FindUser(User, UserRole)
Enum UserRole
Is it ok for FrameLogin to have an user role just because the UI is the same for both?
2. This is my main now:
I have one package for the AdminUI, another for the GamerUI, and for now a CommonUI, where I have the login screen, since it's the same for both.
I think I should apply a factory pattern here, but I'm not sure on how to do it. I thought something like:
But I don't find it consistent. For example, in the FrameLogin, this is how I open another frame:
Any ideas? Thanks!