This project implements a Bike
class in Python using an object oriented approach. The code contains various properties and methods related to a bike. The class allows you to manage the bike's gears, wheels, and brake type, providing a basic interface for interacting with a bike's functionality. The code includes additional error tests to limit values to within acceptable usage based on the requirements provided by the customer.
- Set and get the number of gears.
- Set and get the current gear (default is 1).
- Set and get the number of wheels (1 to 4).
- Set and get the brake type (either "hand brakes" or "foot brakes").
- Reset gears to 1.
- Increase or decrease the current gear, ensuring it stays within valid limits.
- Python 3.12.4 and up
- Clone the repository:
git clone https://github.com/bapriddy/bike-class.git cd bike-class
from bike import Bike
my_bike = Bike(number_gears=5, nummber_wheels=2, brake_type="hand brakes")
my_bike.set_current_gear(3)
print(my_bike.get_current_gear()) # Output: 3
my_bike.increase_gear() # Output 4
my_bike.decrease_gear() # Output 3
my_bike.reset_gears() # back to 1
- Number of Gears
- Current Gear (should default to 1)
- Number of Wheels (1, 2, 3, or 4)
- Brake Type ("hand brakes" or "foot brakes")
- Set & Get Number of Gears
- Set & Get Current Gear
- Set & Get Number of Wheels
- Set & Get Brake Type
- Reset Gears: Set gear back to 1
- Increase Gear: Increase Current Gear by 1, do not allow going over Number of Gears
- Decrease Gear: Decrease Current Gear by 1, do not allow going under 1