Skip to content

Commit 8726d39

Browse files
committed
Refactoring code in main
1 parent 115f5a7 commit 8726d39

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

  • carRentalSystem/src/main/java/com/lld/carRentalSystem

carRentalSystem/src/main/java/com/lld/carRentalSystem/Main.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,29 @@
1616
public class Main {
1717

1818
public static void main(String args[]) {
19-
2019
List<User> users = addUsers();
2120
List<Vehicle> vehicles = addVehicles();
2221
List<Store> stores = addStores(vehicles);
2322

2423
VehicleRentalSystem rentalSystem = new VehicleRentalSystem(stores, users);
2524

26-
//0. User comes
2725
User user = users.get(0);
26+
Location location = new Location(123, "city", "state", "country");
2827

29-
//1. user search store based on location
30-
Location location = new Location(403012, "Bangalore", "Karnataka", "India");
3128
Store store = rentalSystem.getStore(location);
32-
33-
//2. get All vehicles you are interested in (based upon different filters)
3429
List<Vehicle> storeVehicles = store.getVehicles(VehicleType.CAR);
3530

36-
//3.reserving the particular vehicle
3731
Reservation reservation = store.createReservation(storeVehicles.get(0), users.get(0));
3832

39-
//4. generate the bill
4033
Bill bill = new Bill();
4134
bill.setReservation(reservation);
4235

43-
//5. make payment
4436
Payment payment = new Payment();
4537
payment.payBill(bill);
4638

47-
//6. trip completed, submit the vehicle and close the reservation
4839
store.completeReservation(reservation.getResId());
49-
5040
}
5141

52-
53-
5442
public static List<Vehicle> addVehicles(){
5543

5644
List<Vehicle> vehicles = new ArrayList<>();

0 commit comments

Comments
 (0)