MCPcopy Create free account
hub / github.com/Vedenin/useful-java-links / Client

Class Client

helloworlds/4.1-testing/mockito/src/main/java/Client.java:9–54  ·  view source on GitHub ↗

Need for operations to buy. Performs operations over balance. If failed operations buy add CodeError in method Client#addCodeError(CodeError).

Source from the content-addressed store, hash-verified

7 * If failed operations buy add {@link CodeError} in method {@link Client#addCodeError(CodeError)}.
8 */
9class Client {
10 private int balance;
11 private List<CodeError> codeErrors = new ArrayList<>();
12 private List<Product> products = new ArrayList<>();
13
14 Client(int balance) {
15 this.balance = balance;
16 }
17
18 boolean haveAmountOnBalance(int amount) {
19 return (balance >= amount);
20 }
21
22 int getBalance() {
23 return balance;
24 }
25
26 void withdraw(int amount) {
27 balance -= amount;
28 }
29
30 void addCodeError(CodeError codeError) {
31 codeErrors.add(codeError);
32 }
33
34 List<CodeError> getCodeErrors() {
35 return codeErrors;
36 }
37
38 void addProduct(Product product) {
39 products.add(product);
40 }
41
42 List<Product> getProducts() {
43 return products;
44 }
45
46 @Override
47 public String toString() {
48 return "Client{" +
49 "balance=" + balance +
50 ", codeErrors=" + codeErrors +
51 ", products=" + products +
52 '}';
53 }
54}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected