This is a Command-Line Interface (CLI) system developed in Java for managing users and events. It allows you to:
- Register users
- Register events
- Link users to events
- List events by category
- Search users by name
The program is designed using a state machine architecture that controls user navigation through different commands interactively.
The program starts in an interactive menu waiting for a user command. You can list all valid commands by typing listcommands
.
Prints all available commands defined by:
EnumSet.allOf(State.class)
Excludes the none
state, which indicates invalid commands.
Registers a new user with the following details:
- Name
- CPF (Brazilian personal document - parsed and validated)
- Date of Birth (format:
yyyy-MM-dd
)
The Person
object is created and stored in memory.
Searches for users by name (partial match). Displays:
- Name
- CPF
- Date of Birth
- Registered Event (if any)
Allows registering a new event with the following fields:
- Name
- Description
- Address
- Category ID (from 0 to 2 based on predefined array)
- Date and Time (
yyyy-MM-dd HH:mm
)
The event is added to the global asEventList
.
Searches for events by category name and displays:
- Name
- Description
- Date and Time
- Address
- Category
- Participant names
- Event occurrence status (past, present, or future)
Associates a previously registered user to an existing event via:
- Exact event name
- User’s CPF
The link is bidirectional: the event stores the user CPF, and the user references the event.
Immediately terminates the program using System.exit(0)
.
The program uses an enum-based state machine (State
) to control user interaction and command flow.
Data is stored in static lists within Data_Read_Write
:
asPersonaList
— list of usersasEventList
— list of events
Person
: Represents a user with fields like name, CPF, and birthdate.EventUnique
: Represents an event with details like name, category, and participant list.Data_Read_Write
: Provides static access to user and event lists.State
: Enum defining all available states/commands.
- User input is read using
Scanner
- Dates are parsed using Java’s
LocalDateTime
- Integer and string inputs are validated
The helper method getString()
determines the temporal status of an event:
- Future event:
"The event has not happened yet."
- Same day:
"The event is happening now."
- Past:
"The event has already occurred."
- JDK 11 or higher
- Java-compatible terminal
javac -d out src/org/example/*.java
java -cp out org.example.Main
Command | Description |
---|---|
listcommands |
Lists all available commands |
userregister |
Registers a new user |
searchuserbyname |
Searches for users by name |
eventregister |
Registers a new event |
listeventsbycategory |
Lists events by category |
listeventsbytag |
(Not implemented) |
attach_user_to_event |
Links a user to a selected event |
exit |
Exits the program |
- Add file or database persistence
- Implement
listeventsbytag
- Add internationalization and language support
This project is a solid foundation for a basic CLI-based user and event management system. Its state-driven design makes it easy to expand and maintain, and it's well-suited for educational purposes. Future improvements could turn it into a complete and robust system.