Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qory- Pull Request for Independent Challenge #1 #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

qoryhanisagal
Copy link

Iteration 1 - Passenger Class Implementation

Overview

In Iteration 1, I implemented the Passenger class, which represents passengers in the park's vehicles. The class includes methods to track each passenger's age, determine if they are an adult, and track whether they are a driver.

Key Features Implemented

  • Passenger Class:

    • Initialized with name and age attributes.
    • Tracks whether the passenger is an adult (age 18 or older).
    • Tracks whether the passenger is a driver.
  • Key Methods:

    • initialize: Initializes a Passenger object with name and age.
    • adult?: Returns whether the passenger is an adult (18 or older).
    • driver?: Returns whether the passenger is currently a driver.
    • drive: Marks the passenger as a driver.

Test Coverage

  • I used TDD to verify the behavior of the Passenger class:
    • Correct initialization of passengers with name and age.
    • Accurate determination of whether a passenger is an adult.
    • Correctly tracking when a passenger becomes a driver.

Challenges

  • Handling edge cases where passengers had missing or incorrect age values.
  • Ensuring that the adult? method correctly identifies passengers who are 18 or older.

Fixes

  • Ensured that passengers are initialized with valid attributes, adding default values for missing or invalid data.
  • Corrected the logic in the adult? method to accurately return true only for passengers 18 and older.

Reflection

  • Successfully implemented the Passenger class with all requested features and behavior.
  • All tests have passed, ensuring the class functions correctly for initialization, adult verification, and driver status tracking.

Iteration 2 - Vehicle Class Implementation

Overview

In this iteration, I implemented the Vehicle class, which represents a vehicle with passengers and tracks whether it is speeding. The class includes methods to add passengers, check speeding status, and count adult passengers.

Key Features Implemented

  • Vehicle Class:

    • Initialized with year, make, and model attributes.
    • Tracks whether the vehicle is speeding.
    • Manages passengers inside the vehicle.
  • Key Methods:

    • initialize: Initializes the vehicle with year, make, and model, and defaults for speeding and passengers.
    • speeding?: Returns whether the vehicle is speeding.
    • speed: Sets the vehicle to speeding.
    • add_passenger: Adds a passenger to the vehicle.
    • num_adults: Returns the number of adult passengers in the vehicle.

Test Coverage

  • I used TDD to ensure the Vehicle class behaves as expected:
    • Initialization of vehicles with the correct attributes.
    • Correctly tracking speeding status.
    • Adding passengers and correctly counting the number of adults.

Challenges

  • Handling missing attributes during initialization (e.g., nil values for year).
  • Ensuring accurate counting of adult passengers in the vehicle.

Fixes

  • Addressed failing tests related to missing attributes by adding default values.
  • Ensured that the speeding? method reflects the vehicle’s true speeding status after calling the speed method.
  • Corrected test expectations for the number of adult passengers.

Reflection

  • Successfully implemented all features for the Vehicle class using TDD.
  • All tests have passed, and the class is ready for further integration with the rest of the system.

Iteration 3 & 4 - Park Class Implementation and Enhancements

Overview

In Iteration 3 and 4, I implemented the Park class, which manages vehicles entering the park, tracks passengers, and calculates revenue based on adult passengers. Additionally, I enhanced the park's functionality to list all attendees, minors, and adults, all sorted alphabetically.

Key Features Implemented

Iteration 3:

  • Park Class:

    • Initialized with a name and admission_price.
    • Manages vehicles entering the park.
    • Tracks all passengers from vehicles that have entered the park.
  • Key Methods:

    • initialize: Initializes the park with name, admission_price, and an empty vehicles array.
    • add_vehicle: Adds a vehicle to the park.
    • passengers: Returns a list of all passengers from the vehicles in the park.
    • revenue: Calculates revenue based on the number of adult passengers and the admission price.

Iteration 4:

  • Additional Methods:
    • all_attendees: Returns a list of names of all attendees (passengers) sorted alphabetically.
    • minors: Returns a sorted list of minors (passengers under 18) in the park.
    • adults: Returns a sorted list of adults (passengers 18 and older) in the park.

Test Coverage

  • I used TDD to verify the behavior of the Park class:
    • Initialization of the park with the correct attributes.
    • Properly adding vehicles and passengers to the park.
    • Correctly listing all passengers, adults, and minors in the park.
    • Accurate calculation of revenue based on the number of adult passengers.
    • Sorting attendees, minors, and adults alphabetically.

Challenges

  • Handling edge cases such as no adults in the park and ensuring revenue is correctly calculated in such scenarios.
  • Ensuring that the sorting logic for attendees, minors, and adults works as expected with various input data.

Fixes

  • Addressed issues where revenue wasn't calculated correctly by counting adult passengers properly.
  • Ensured that the lists of attendees, minors, and adults are returned in alphabetical order.
  • Corrected tests where passenger counting was inaccurate due to missing or incorrect test expectations.

Reflection

  • Successfully implemented the full Park class functionality with all requested features and enhancements.
  • The class is fully tested, and all tests have passed, ensuring correct behavior of all methods, including edge cases and sorting logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant