Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AllCars {
- private Car[] cars;
- private int num;
- public AllCars(int max) {
- this.cars = new Car[max];
- this.num = 0;
- }
- public boolean addCar(Car car){
- if(this.num == this.cars.length)
- return false;
- else{
- cars[num] = car;
- num++;
- return true;
- }
- }
- public void print(int min, int max){
- for (int i = 0; i < this.cars.length; i++) {
- Car car = this.cars[i];
- if(!car.hadAccident() && car.range(min, max))
- System.out.println("car license:"+car.getLicenseNum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement