Package customer
Class Customer
java.lang.Object
customer.Customer
- All Implemented Interfaces:
IGiveBetList
- Direct Known Subclasses:
GoldCustomer,PlatinumCustomer
public sealed class Customer
extends Object
implements IGiveBetList
permits GoldCustomer, PlatinumCustomer
Represents a customer with betting capabilities, including a list of bets, total gains,
and spending information.
This class can be extended to support various customer tiers (e.g., Basic, Gold, Platinum),
each with a different betting limit defined by CustomerType.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<CustomerBet> A list ofCustomerBetobjects placed by the customer.private final StringThe full name of the customer.private final intThe maximum stake the customer can place on any bet.private doubleThe total amount of money the customer has gained from their successful bets.private doubleThe total amount of money the customer has spent on placing bets. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a customer with a basic betting limit, corresponding to theCustomerType.BASICtype.Customer(String fullName, CustomerType customerType) Constructs a customer with a specified customer type that determines the betting limit. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCustomerBet(CustomerBet customerBet) Adds a new bet to the customer's list of bets.Retrieves the list of bets placed by this customer.intGets the maximum stake limit for the customer based on theirCustomerType.voidincreaseTotalGains(double gain) Increases the customer's total gains by a specified amount.voidincreaseTotalSpent(double spent) Increases the total amount the customer has spent on bets by a specified amount.toString()Returns a string representation of the customer, including their full name, total amount spent, and total gains.
-
Field Details
-
fullName
The full name of the customer. -
maxStake
private final int maxStakeThe maximum stake the customer can place on any bet.This field is determined by the customer's type (Basic, Gold, Platinum) and reflects the maximum amount the customer is allowed to bet on any single bet.
-
customerBets
A list ofCustomerBetobjects placed by the customer. -
totalGains
private double totalGainsThe total amount of money the customer has gained from their successful bets. -
totalSpent
private double totalSpentThe total amount of money the customer has spent on placing bets.
-
-
Constructor Details
-
Customer
Constructs a customer with a basic betting limit, corresponding to theCustomerType.BASICtype.- Parameters:
fullName- The full name of the customer.
-
Customer
Constructs a customer with a specified customer type that determines the betting limit.- Parameters:
fullName- The full name of the customer.customerType- The type of customer (e.g.,CustomerType.GOLD,CustomerType.PLATINUM), which sets the maximum stake limit.
-
-
Method Details
-
getMaxStake
public int getMaxStake()Gets the maximum stake limit for the customer based on theirCustomerType.- Returns:
- The maximum stake amount allowed for this customer, as determined by their customer type.
-
addCustomerBet
Adds a new bet to the customer's list of bets.- Parameters:
customerBet- TheCustomerBetobject representing the bet to be added.
-
increaseTotalGains
public void increaseTotalGains(double gain) Increases the customer's total gains by a specified amount.- Parameters:
gain- The amount to add to the customer's total gains.
-
increaseTotalSpent
public void increaseTotalSpent(double spent) Increases the total amount the customer has spent on bets by a specified amount.- Parameters:
spent- The amount to add to the customer's total spent amount.
-
getCustomerBetList
Retrieves the list of bets placed by this customer.- Specified by:
getCustomerBetListin interfaceIGiveBetList- Returns:
- A
ListofCustomerBetobjects representing the bets placed by the customer.
-
toString
-