refact Tp2.java