{"id":27156043,"url":"https://github.com/it21826740/vehicle-management-system","last_synced_at":"2025-04-08T19:57:40.090Z","repository":{"id":251926377,"uuid":"838868173","full_name":"IT21826740/Vehicle-Management-System","owner":"IT21826740","description":"a real-world example question that involves both method overloading and method overriding in Java.","archived":false,"fork":false,"pushed_at":"2024-08-07T15:09:21.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-07T18:15:15.574Z","etag":null,"topics":["java","learn-java","overloading","overriding","self-try","vehicle-management-system"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IT21826740.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-06T13:55:43.000Z","updated_at":"2024-08-07T15:11:06.000Z","dependencies_parsed_at":"2024-08-07T18:04:12.839Z","dependency_job_id":null,"html_url":"https://github.com/IT21826740/Vehicle-Management-System","commit_stats":null,"previous_names":["it21826740/vehicle-management-system"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IT21826740%2FVehicle-Management-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IT21826740%2FVehicle-Management-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IT21826740%2FVehicle-Management-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IT21826740%2FVehicle-Management-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IT21826740","download_url":"https://codeload.github.com/IT21826740/Vehicle-Management-System/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247918914,"owners_count":21018044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","learn-java","overloading","overriding","self-try","vehicle-management-system"],"created_at":"2025-04-08T19:57:39.434Z","updated_at":"2025-04-08T19:57:40.076Z","avatar_url":"https://github.com/IT21826740.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vehicle-Management-System\n\n a real-world example question that involves both method overloading and method overriding in Java:\n\n## Question: Vehicle Management System\n\n### Problem Statement\n\nYou are tasked with developing a simple vehicle management system for a vehicle rental company. The system needs to manage different types of vehicles and calculate rental costs based on the type and rental duration. You need to implement the following:\n\n1. **Vehicle Class**:\n   - A base class `Vehicle` with attributes `make`, `model`, and `year`.\n   - A method `getRentalCost(int days)` to calculate the rental cost.\n\n2. **Car and Bike Classes**:\n   - Two derived classes `Car` and `Bike` that inherit from `Vehicle`.\n   - Override the `getRentalCost(int days)` method to provide specific rental cost calculations for cars and bikes.\n\n3. **Rental Cost Calculation**:\n   - The base `Vehicle` class should provide a default rental cost calculation.\n   - The `Car` class should charge a flat rate per day plus an additional fee for each day.\n   - The `Bike` class should charge a flat rate per day with no additional fees.\n\n4. **Method Overloading**:\n   - Overload the `getRentalCost` method in the `Vehicle` class to allow calculating the rental cost for both days and hours. The method `getRentalCost(int days, int hours)` should calculate the cost by converting hours to a fraction of a day.\n\n### Requirements\n\n1. **Vehicle Class**:\n   - Attributes: `make` (String), `model` (String), `year` (int).\n   - Methods:\n     - `getRentalCost(int days)`: Returns the rental cost for the given number of days.\n     - `getRentalCost(int days, int hours)`: Returns the rental cost for the given number of days and hours.\n\n2. **Car Class**:\n   - Inherits from `Vehicle`.\n   - Overrides `getRentalCost(int days)` to charge $50 per day plus $20 additional fee for each day.\n\n3. **Bike Class**:\n   - Inherits from `Vehicle`.\n   - Overrides `getRentalCost(int days)` to charge $20 per day with no additional fees.\n\n4. **Main Program**:\n   - Create instances of `Car` and `Bike`.\n   - Demonstrate method overloading and overriding by calculating rental costs for different durations.\n\n### Example Output\n```\nCar Rental for 3 days: $210\nCar Rental for 2 days and 12 hours: $180\nBike Rental for 3 days: $60\nBike Rental for 2 days and 12 hours: $50\n```\n\n\n\n### Explanation of Features\n\n1. **Method Overloading**:\n   - The `getRentalCost(int days)` method is overloaded with another method `getRentalCost(int days, int hours)` in the `Vehicle` class to handle both days and hours.\n\n2. **Method Overriding**:\n   - The `Car` and `Bike` classes override the `getRentalCost(int days)` method from the `Vehicle` class to provide specific rental cost calculations.\n\nThis example allows you to demonstrate understanding and implementation of both method overloading and overriding in a practical scenario.\n\nSELF TRY - LEARN JAVA - Q2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fit21826740%2Fvehicle-management-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fit21826740%2Fvehicle-management-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fit21826740%2Fvehicle-management-system/lists"}