Package userservice
Class User
java.lang.Object
userservice.User
A class for creating a user.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBankAccount
(BankAccount bankAccount) Give the user a bank account.void
Add an email to theArrayList
of email addressesvoid
addPhoneNumber
(String phoneNumber) Add a phone number to the user.int
getAge()
Get the age of the user.Get theArrayList
of bank accounts from a user.Get anArrayList
of email addresses linked to the user.getName()
Get the name of the user.Get anArrayList
of phone numbers linked to the user.int
Get the ID of the user.void
Increment the age of the user by one.void
removeBankAccount
(BankAccount bankAccount) Remove a bank account from the user.void
removeEmail
(String email) Remove an email address from the user.void
removePhoneNumber
(String phoneNumber) Remove a phone number from the user.void
setAge
(int age) Set the age of the user.void
Set the name of the user.void
setUserId
(int userId) Set the ID of the user.toString()
-
Constructor Details
-
User
Create a user.- Parameters:
name
- The name of the user.age
- The age of the user.userId
- The user ID.
-
User
Create a user with an email address.- Parameters:
name
- The name of the user.age
- The age of the user.userId
- The user ID.email
- An email address.
-
User
Create a user with an phone number.- Parameters:
name
- The name of the user.age
- The age of the user.userId
- The user ID.email
- An email address.phoneNumber
- A phone number.
-
-
Method Details
-
getName
Get the name of the user.- Returns:
- The name of the user.
-
setName
Set the name of the user.- Parameters:
name
- The name of the user.
-
getAge
public int getAge()Get the age of the user.- Returns:
- The age of the user.
-
setAge
Set the age of the user.- Parameters:
age
- The age of the user.- Throws:
IllegalArgumentException
- If age is 0 or below.
-
incrementAge
public void incrementAge()Increment the age of the user by one. -
getUserId
public int getUserId()Get the ID of the user.- Returns:
- The ID of the user.
-
setUserId
public void setUserId(int userId) Set the ID of the user.- Parameters:
userId
- The ID of the user.
-
getBankAccounts
Get theArrayList
of bank accounts from a user.- Returns:
- An
ArrayList
of BankAccount classes.
-
addBankAccount
Give the user a bank account.- Parameters:
bankAccount
- The bank account to be added.
-
removeBankAccount
Remove a bank account from the user.- Parameters:
bankAccount
- The bank account to be removed.
-
addEmail
Add an email to theArrayList
of email addresses- Parameters:
email
- The email to be added.
-
removeEmail
Remove an email address from the user.- Parameters:
email
- The email to be removed.
-
getEmailAddresses
Get anArrayList
of email addresses linked to the user.- Returns:
- An
ArrayList
of email addresses.
-
addPhoneNumber
Add a phone number to the user.- Parameters:
phoneNumber
- The phone number to be added.
-
removePhoneNumber
Remove a phone number from the user.- Parameters:
phoneNumber
- The phone number to be removed.
-
getPhoneNumbers
Get anArrayList
of phone numbers linked to the user.- Returns:
- An
ArrayList
of phone numbers.
-
toString
-