commit
						182e57afb4
					
				
							
								
								
									
										14
									
								
								src/Bus.java
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/Bus.java
									
									
									
									
									
								
							@ -1,14 +1,26 @@
 | 
			
		||||
 | 
			
		||||
public class Bus extends CivilVehicle {
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	private String UID;
 | 
			
		||||
	private static int numeberOfBuses;
 | 
			
		||||
    private final int TIME_TO_FIX = 20; //in minutes
 | 
			
		||||
 | 
			
		||||
    public Bus(double vehicleSize) {
 | 
			
		||||
        super(vehicleSize);
 | 
			
		||||
        generateUID();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getTimeToFix() {
 | 
			
		||||
        return TIME_TO_FIX;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private void generateUID() {
 | 
			
		||||
        numeberOfBuses++;
 | 
			
		||||
        this.UID = String.format("BUS%04d", numeberOfBuses);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getUID(){
 | 
			
		||||
        return this.UID;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,16 +1,17 @@
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
public class Campaign {
 | 
			
		||||
 | 
			
		||||
    private String UID;
 | 
			
		||||
    //private int housingNumber;
 | 
			
		||||
    private String name;
 | 
			
		||||
    //private String name; //TODO äÈÛÇ ÑÇíß íÇ åÔÇã (:  
 | 
			
		||||
    private District hotelDistrict;
 | 
			
		||||
 | 
			
		||||
    private Route housingToDestRoute;
 | 
			
		||||
    private Route destToHousingRoute;
 | 
			
		||||
 | 
			
		||||
    private Vehicle[] vehicles;
 | 
			
		||||
    private ArrayList<Vehicle> vehicles;
 | 
			
		||||
 | 
			
		||||
    //Will be of type PDate after extention
 | 
			
		||||
    private Date timeToLeaveToDest;
 | 
			
		||||
@ -24,7 +25,7 @@ public class Campaign {
 | 
			
		||||
        generateUID();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Campaign(District hotelDistrict, Vehicle[] vehicles) {
 | 
			
		||||
    public Campaign(District hotelDistrict, ArrayList<Vehicle> vehicles) {
 | 
			
		||||
        this.hotelDistrict = hotelDistrict;
 | 
			
		||||
        setVehicles(vehicles);
 | 
			
		||||
        generateUID();
 | 
			
		||||
@ -76,21 +77,28 @@ public class Campaign {
 | 
			
		||||
        return busses;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Vehicle[] getVehicles() {
 | 
			
		||||
        return this.vehicles;
 | 
			
		||||
    }
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
    public ArrayList<Vehicle> getVehicles() {
 | 
			
		||||
		return vehicles;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setVehicles(ArrayList<Vehicle> vehicles) {
 | 
			
		||||
		if (vehicles != null)
 | 
			
		||||
		this.vehicles = vehicles;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public void setVehicles(Vehicle[] vehicles){
 | 
			
		||||
        /*TODO: Osama check if vehicles is not null then set vehicles. */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void generateBusses(int number){
 | 
			
		||||
        /*TODO: Asaad generate "number"  of busses and set them to vehicles array. */
 | 
			
		||||
    	for (int i = 1; i <= number; i++) {
 | 
			
		||||
    		vehicles.add(new Bus(10));
 | 
			
		||||
    		
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void generateUID() {
 | 
			
		||||
        numeberOfCampains++;
 | 
			
		||||
        this.UID = String.format("%04d", numeberOfCampains);
 | 
			
		||||
        this.UID = String.format("CAMP%04d", numeberOfCampains);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getUID(){
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,3 @@
 | 
			
		||||
public interface CanBeGovtCar {
 | 
			
		||||
    int getGovtID();
 | 
			
		||||
    void generateGovtID();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,8 @@
 | 
			
		||||
public class TrafficPoliceCar extends Vehicle implements CanBeGovtCar, CanFixAccident {
 | 
			
		||||
 | 
			
		||||
    private final double ADDED_EFFICIENCY = 0.05; // 5%
 | 
			
		||||
    private int govtID;
 | 
			
		||||
    private String TPC_UID;
 | 
			
		||||
    private static int numeberOfTPC;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * construct instance with random GovtID
 | 
			
		||||
@ -9,7 +10,7 @@ public class TrafficPoliceCar extends Vehicle implements CanBeGovtCar, CanFixAcc
 | 
			
		||||
     */
 | 
			
		||||
    public TrafficPoliceCar(double vehicleSize){
 | 
			
		||||
        super(vehicleSize);
 | 
			
		||||
        //TODO: Osamah Set random govtID
 | 
			
		||||
        getGovtID();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -17,13 +18,20 @@ public class TrafficPoliceCar extends Vehicle implements CanBeGovtCar, CanFixAcc
 | 
			
		||||
     * @param vehicleSize Length of vehicle in meters
 | 
			
		||||
     * @param govtID Provided Govt ID
 | 
			
		||||
     */
 | 
			
		||||
    public TrafficPoliceCar(double vehicleSize, int govtID) {
 | 
			
		||||
        super(vehicleSize);
 | 
			
		||||
        this.govtID = govtID;
 | 
			
		||||
    }
 | 
			
		||||
//    public TrafficPoliceCar(double vehicleSize, int govtID) {
 | 
			
		||||
//        super(vehicleSize);
 | 
			
		||||
//        this.govtID = govtID;
 | 
			
		||||
//    } //TODO ãÇ íÍÊÇÌ ÇääÇ ääÔÆ íæ Çí Ïí ÈãÇ Çäå ÇáÇäÔÇÁ Ú ÇáÓÊÇÊß 
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getGovtID() {
 | 
			
		||||
        return govtID;
 | 
			
		||||
    public void generateGovtID(){
 | 
			
		||||
    	numeberOfTPC++;
 | 
			
		||||
    	this.TPC_UID = String.format("TPC%03d", numeberOfTPC);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    public String getGovtID() {
 | 
			
		||||
    	return this.TPC_UID;
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user