Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public String toString() {
  2.  
  3. if(!tavarat.isEmpty() && tavarat.size() > 1) {
  4. int yhteispaino = 0;
  5. for (int i = 0; i < tavarat.size(); i++) {
  6.  
  7. yhteispaino = yhteispaino + tavarat.get(i).getPaino();
  8.  
  9. }
  10. return tavarat.size() + " tavaraa " + "(" + yhteispaino + " kg)";
  11. }else if (tavarat.size() == 1) {
  12.  
  13. return "1 tavara " + "(paino " + this.yhteispaino() + ")";
  14.  
  15. }else{
  16.  
  17. return "ei tavaroita (0 kg)";
  18. }
  19.  
  20. }
Add Comment
Please, Sign In to add comment