EU | fintech | phone screen - How to solve?
Anonymous User
193

Hello everyone!

Got this today at onsite at EU fintech company:

public interface RateService {
     public ToDo calculate(Todo todo) {
	     return ToDo; 
	 }
}

public class ClientService {
     RateService rateService; // already inject
	 
	 public Todo calculate(ToDo todo) {
	     return ToDo;
	 }
}

I need to design and develop service, which calculate the total sum before exchange operation. Example: user sell 100 EUR, receive 119 USD, etc ( GBP ->EUR / RUB -> USD )
Rates comes from external "service" interface, which each call costs to company 0.001$ and Client Service should have lattency 200ms. And I need to design classes and write code.

My idea was: Create class / HashSet for storing rate info / queue for delete old rate from out hashSet

Created a class: for save info from rateService.
class Currency {
  private String debitCurrency;
  private String creditCurrency;
  private BigDecimial rate;
  private Long timeStamp;
  
  // getters , setters, equals, hashCode, construtors 
}

Function and internal logic

public BigDecemial calculate(BigDecemial amount, String debitCCY, String creditCCY) {
    // Create object of currency class, using debitCCY, creditCCY and timeStamp
	// check if this object is too old for getting currency from it and we need to delete from queue and hashSet 
	
	// if object exist in hashset, calculate amount based on rate
	// else get info from service, put in hashSet, queue
	
	// return to customer
}

How you will be design this in 40 minutes ?

There is no need to RUN code.

Comments (3)