Created
February 5, 2022 06:38
-
-
Save raghavddps2/98f5465b0048da9c25b2d054167c751f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Vehicle | |
| - double calculateCo2Emission(Trip t) | |
| class Car implements Vehicle | |
| - double calculateCo2Emission(Trip t) | |
| * valueFromHashMap * t.distanceInKm | |
| class Train implements Vehicle | |
| - double calculateCo2Emission(Trip t) | |
| * valueFromHashMap * t.distanceInKm | |
| class Bus implements Vehicle | |
| - double calculateCo2Emission(Trip t) | |
| * valueFromHashMap * t.distanceInKm | |
| Trip | |
| basic variables | |
| - String transportationMethod; | |
| - double distance | |
| - String unitOfDistance | |
| - String preferredCo2Unit | |
| formed variables | |
| - Vehicle vehicle | |
| - double distanceInKm | |
| method | |
| - calculateCo2Emission() | |
| - vehicle.calculateCo2Emission(this) | |
| - if preferredCo2Unit is g, multiply 1000 | |
| - return the amount | |
| Main | |
| - String input | |
| - send parameters to trip class | |
| - Based on the transportationMethod, it sets the | |
| vehicle required. | |
| - trip.calculateCo2Emission() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment