Advertisement
Guest User

carrental

a guest
Apr 1st, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.ArrayList;
  2. public class Carrental
  3. {
  4. public ArrayList<Car> cars;
  5. public Carrental()
  6. {
  7. cars = new ArrayList<Car>();
  8. }
  9. public int averageDistance()
  10. {
  11. int total = 0;
  12. for(Car c : cars)
  13. {
  14. total += c.getDistance();
  15. }
  16. return total / cars.size();
  17. }
  18. public void longestRental()
  19. {
  20. long total = 0;
  21. for(Car c : cars)
  22. {
  23. if(c.Calculate() > total)
  24. {
  25. total = c.Calculate();
  26. }
  27. }
  28. System.out.println("langste huurperiode " + total/(60*60*1000*24));
  29. }
  30. public void totalProfit()
  31. {
  32. int total = 0;
  33. for(Car c : cars)
  34. {
  35. total += c.showPrice();
  36. }
  37. System.out.println("totale profit: " + total);
  38. }
  39. public void add(Car c)
  40. {
  41. cars.add(c);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement