Advertisement
moreiramota

Untitled

Jan 9th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public boolean endJourney(GraphHandler graph) {
  2. try {
  3. Route local = routes.get(routes.size() - 1);
  4. Park destination = Park.getPark(local.getLocation().getLatitude(), local.getLocation().getLongitude());
  5. Bicycle b = this.getBicycle();
  6. if (b.getType() == 1) {
  7. EBicycle eB = (EBicycle) b;
  8. Battery ba = eB.getBattery();
  9. double energyJourney = calculateEnergyDuringJourney(this, graph);
  10. double remaining = ba.getBatteryRemaining();
  11. ba.setBatteryRemaining(remaining - (0.6 * energyJourney));
  12. ba.setLastUpdate(local.getVisitDate());
  13. eB.saveBicycle();
  14. }
  15.  
  16. if (destination.addBicycle(idBicycle) == null) {
  17. return false;
  18. }
  19. destination.save();
  20.  
  21. calculateMonthYear();
  22. calculatePrice();
  23. return true;
  24. } catch (Exception ex) {
  25. return false;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement