You are on page 1of 3

Coding tasks

The following tasks are dealing with Java code. We really like testable code, so take your time to make something clean and neat. All tasks has multiple right solution

Task 1: Triangles
Write a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error).

Task 2: Modular string processor

User story: As a GUI developer I would like some code I can call to format large text strings, so I can change text format as I wish Acceptance Make all Letters capital Put brackets around the entire string Replace spaces with - Code should be extendable for further formats

Task 3: Review a method

You are reviewing your peer's code and come across the following method. What feedback would you supply?
public static final Integer doThis(Integer x, Integer y) { return (y == 0) ? 0 : doThis (x, y - 1) + x; }

Task 4: Review another method

While reviewing another part of the application, you come across this method. What would your feedback to the author be?
public LinkedList findOrdersForProduct(Product p, boolean debug) { ArrayList l = new ArrayList(); ArrayList list = getAllOrders(); for (int i=0; i<list.size(); i++) { Order order = (Order) list.get(0); boolean found = false; if (order.getProducts().size() > 0) { for (int j=0; j<=order.getProducts().size(); j++) { Product p2 = order.getProducts().get(j); found = (p2 == p); } if (found && order != null) l.add(order); } } return new LinkedList(l); }

Task 5: Create an implementation class for BankAccount

The class must be able to handle multi threaded access. Create a unit test for your implementation class.
public abstract class BankAccount { protected int creditLimit; /** * Creates a new BankAcount * * @param creditLimit The Maximum amount of money this account can be * overdrawn with. */ BankAccount(int creditLimit) { this.creditLimit = creditLimit; } /** * Deposit money to account. * * @param amount The amount of money to be deposit to this account. */ public abstract void deposit(int amount); /** * Withdraw money from account * * @param amount The amount of money to be withdrawn from this account. * @throws NotEnoughMoneyException if the requested amount to be withdrawn exceeds * the credit limit. */ public abstract void withdraw(int amount) throws NotEnoughMoneyException; /** * Get balance from account. * * @return The balance of this account. */ public abstract int balance(); }