Advertisement
Guest User

Traffic class

a guest
Jan 22nd, 2020
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None
  1. class Traffic {
  2. import java.util.Map;
  3.  
  4. int carNum;
  5. int[] speedArray = new int[carNum];
  6. Car[] carArray = new Car[carNum];
  7. private Map cars = new HashMap();
  8.  
  9. Traffic(int tempCarNum, int tempSpeed){
  10. carNum = tempCarNum;
  11. for(int n = 0; n < speedArray.length; n++) {
  12. speedArray[n] = tempSpeed;
  13. }
  14. }
  15.  
  16. void createObject() {
  17. for(int i = 0; i < carNum; i++) {
  18. carArray[i] = new Car(30, 300, color(255, 0, 0), color(100, 255, 100), 10, true);
  19.  
  20. }
  21. }
  22.  
  23. void addCar(String carID, Car car) {
  24. cars.put(carID, car);
  25. }
  26.  
  27. private Car getCar(String carID) {
  28. return cars.get(carID);
  29. }
  30. }
Advertisement
RAW Paste Data Copied
Advertisement