Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean endJourney(GraphHandler graph) {
- try {
- Route local = routes.get(routes.size() - 1);
- Park destination = Park.getPark(local.getLocation().getLatitude(), local.getLocation().getLongitude());
- Bicycle b = this.getBicycle();
- if (b.getType() == 1) {
- EBicycle eB = (EBicycle) b;
- Battery ba = eB.getBattery();
- double energyJourney = calculateEnergyDuringJourney(this, graph);
- double remaining = ba.getBatteryRemaining();
- ba.setBatteryRemaining(remaining - (0.6 * energyJourney));
- ba.setLastUpdate(local.getVisitDate());
- eB.saveBicycle();
- }
- if (destination.addBicycle(idBicycle) == null) {
- return false;
- }
- destination.save();
- calculateMonthYear();
- calculatePrice();
- return true;
- } catch (Exception ex) {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement