Package userservice
Class User
java.lang.Object
userservice.User
A class for creating a user.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBankAccount(BankAccount bankAccount) Give the user a bank account.voidAdd an email to theArrayListof email addressesvoidaddPhoneNumber(String phoneNumber) Add a phone number to the user.intgetAge()Get the age of the user.Get theArrayListof bank accounts from a user.Get anArrayListof email addresses linked to the user.getName()Get the name of the user.Get anArrayListof phone numbers linked to the user.intGet the ID of the user.voidIncrement the age of the user by one.voidremoveBankAccount(BankAccount bankAccount) Remove a bank account from the user.voidremoveEmail(String email) Remove an email address from the user.voidremovePhoneNumber(String phoneNumber) Remove a phone number from the user.voidsetAge(int age) Set the age of the user.voidSet the name of the user.voidsetUserId(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 email and a 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 theArrayListof bank accounts from a user.- Returns:
- An
ArrayListof 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 theArrayListof 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 anArrayListof email addresses linked to the user.- Returns:
- An
ArrayListof 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 anArrayListof phone numbers linked to the user.- Returns:
- An
ArrayListof phone numbers.
-
toString
-