Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Carrental
- {
- public ArrayList<Car> cars;
- public Carrental()
- {
- cars = new ArrayList<Car>();
- }
- public int averageDistance()
- {
- int total = 0;
- for(Car c : cars)
- {
- total += c.getDistance();
- }
- return total / cars.size();
- }
- public void longestRental()
- {
- long total = 0;
- for(Car c : cars)
- {
- if(c.Calculate() > total)
- {
- total = c.Calculate();
- }
- }
- System.out.println("langste huurperiode " + total/(60*60*1000*24));
- }
- public void totalProfit()
- {
- int total = 0;
- for(Car c : cars)
- {
- total += c.showPrice();
- }
- System.out.println("totale profit: " + total);
- }
- public void add(Car c)
- {
- cars.add(c);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement