Package passport.domain.models.users
Class User
java.lang.Object
passport.domain.models.users.User
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for creating a new user with login and personal details.Constructor for creating a new user with a specified ID, login, and personal details.Private constructor for creating a new user with all details. -
Method Summary
Modifier and TypeMethodDescriptionasAdmin()Promotes the user to admin.voidBuys a ticket and adds it to the user's bought tickets.copy()booleanbooleaninthashCode()id()Returns the user ID.booleanisAdmin()Checks if the user is an admin.booleanChecks if the user owns the specified login.login()Returns the login details.person()Returns the personal details.voidreturnTicket(Ticket ticket) Returns a ticket and removes it from the user's bought tickets.tickets()Returns the list of bought tickets.Sets the login details for the user.Sets the personal details for the user.withTickets(List<Ticket> tickets) Sets the tickets for the user.
-
Constructor Details
-
User
-
User
-
User
Private constructor for creating a new user with all details.- Parameters:
id- the user IDlogin- the login detailsperson- the personal detailsadmin- whether the user is an admintickets- the list of bought tickets
-
-
Method Details
-
withTickets
-
isOwnerOf
Checks if the user owns the specified login.- Parameters:
login- the login to check- Returns:
- true if the user owns the login, false otherwise
-
buyTicket
Buys a ticket and adds it to the user's bought tickets.- Parameters:
ticket- the ticket to buy
-
returnTicket
Returns a ticket and removes it from the user's bought tickets.- Parameters:
ticket- the ticket to return
-
id
-
login
-
person
-
isAdmin
public boolean isAdmin()Checks if the user is an admin.- Returns:
- true if the user is an admin, false otherwise
-
tickets
-
asAdmin
-
with
-
with
-
copy
-
hashCode
-
equals
-
equals
-