Need for operations to buy. Performs operations over balance. If failed operations buy add CodeError in method Client#addCodeError(CodeError).
| 7 | * If failed operations buy add {@link CodeError} in method {@link Client#addCodeError(CodeError)}. |
| 8 | */ |
| 9 | class 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected