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

Hannah Gray- Final Pull/Commit Messages #612

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ff314fa
Implement VehicleFactory to process external data
hanbanfan Dec 12, 2024
ad18eb8
Implement VehicleFactory to process external data
hanbanfan Dec 12, 2024
e58fe59
vehicle factory implementation
hanbanfan Dec 12, 2024
acf20f8
Add .DS_Store to .gitignore
hanbanfan Dec 12, 2024
fa6cf80
Implement VehicleFactory to process external data
hanbanfan Dec 12, 2024
99fbd6e
Add .DS_Store to .gitignore
hanbanfan Dec 12, 2024
054cf2b
Fix Dmv class: add facilities reader and facilities_offering_service …
hanbanfan Dec 13, 2024
02e805d
Add Dmv class with facility management methods
hanbanfan Dec 17, 2024
57796be
Add RSpec tests for Dmv class
hanbanfan Dec 17, 2024
cb4bc29
added facility class
hanbanfan Dec 17, 2024
e472486
added facility spec
hanbanfan Dec 17, 2024
f5344b6
Add registration functionality to Vehicle class and implement Facilit…
hanbanfan Dec 17, 2024
bfb44be
Add RSpec tests for Vehicle registration and Facility services
hanbanfan Dec 17, 2024
ecebd20
Fix Dmv class implementation and update tests
hanbanfan Dec 17, 2024
fa4dec0
FIXED AND UPDATE DMV CLASS AND IMPLEMENTATION TESTS 3
hanbanfan Dec 17, 2024
e72178e
Merge branch 'feature/vehicle-registration'
hanbanfan Dec 17, 2024
f429a6d
Merge all changes into main and prepare for push 3
hanbanfan Dec 17, 2024
8ac50ac
Add Vehicle class with registration and plate determination
hanbanfan Dec 17, 2024
aa9853f
Add RSpec tests for Vehicle class
hanbanfan Dec 17, 2024
d0a63c6
Add Registrant class for managing user permits and licenses
hanbanfan Dec 17, 2024
8dd63fd
Add Registrant class for managing user permits and licenses
hanbanfan Dec 17, 2024
15bdb1e
Add RSpec tests for Registrant, VehicleFactory, and FacilityFactory c…
hanbanfan Dec 17, 2024
6078480
added facility factory
hanbanfan Dec 17, 2024
7f805f4
updated vehicle class
hanbanfan Dec 17, 2024
4e29f79
Fix Facility class to accept a hash for initialization
hanbanfan Dec 18, 2024
1d7655c
Update Facility spec to use hash for initialization
hanbanfan Dec 18, 2024
e6c34b7
Update Dmv spec to use updated Facility initialization
hanbanfan Dec 18, 2024
4d15741
Fix Vehicle class to include registration_date
hanbanfan Dec 18, 2024
a512de3
Update Vehicle spec to test registration_date
hanbanfan Dec 18, 2024
d5580c6
facility factor class
hanbanfan Dec 18, 2024
4489d3b
set up tests for facility factory
hanbanfan Dec 18, 2024
a2e2fcf
Merge feature/facility-class into main
hanbanfan Dec 18, 2024
7f21c63
Merge feature/vehicle-class into main
hanbanfan Dec 18, 2024
30f551d
Merge feature/registrant-factories into main
hanbanfan Dec 18, 2024
27bcbc4
Update README to explain project work
hanbanfan Dec 18, 2024
641cb90
Update README to explain project work
hanbanfan Dec 18, 2024
92d1838
Update README to explain project work
hanbanfan Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
.DS_Store
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# The DMV
DMV Project
What I Did

This is the starter repo for the BE Mod1 DMV project.
This project simulates a DMV system using Ruby and follows Object-Oriented Programming (OOP) principles and Test-Driven Development (TDD).

Facility Management: Created a Facility class to track DMV locations and their services.

Vehicle Management: Built a Vehicle class to handle vehicle registrations, plate types (regular, electric, antique), and registration dates.

Registrant Services: Added a Registrant class to manage individual permits, written tests, road tests, and license renewals.

Data Integration: Integrated external data sources using the DmvDataService class to fetch DMV facilities and vehicle registration data.

Factories: Created VehicleFactory and FacilityFactory classes to process and build objects from external data.
Testing: Used RSpec to test all classes, methods, and edge cases for correctness and reliability.
Key Features
Vehicle registration and classification.
Facility services like written tests, road tests, and license renewals.
Importing and managing DMV data from external APIs.
Comprehensive testing to ensure functionality.
32 changes: 28 additions & 4 deletions lib/dmv.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anytime you see <<<<< and ===== symbols, those indicate the presence of a merge conflict and technically the merge conflict is not resolved until these symbols are cleared. In its current state, this class is not stable/usable until that merge conflict is resolved. Notice that this top section is the initial starter code for this class.

# The Dmv class represents the core DMV system that manages facilities.
class Dmv
# Provides read access to the list of facilities.
attr_reader :facilities

# Initializes the Dmv object with an empty array of facilities.
=======
# The Dmv class represents the DMV system that manages facilities.
class Dmv
attr_reader :facilities

# Initializes an empty array to store Facility objects.
>>>>>>> feature/vehicle-class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are your additions to the class. You can remove the duplication so that it's just one single class with the necessary attr_readers, initialize and methods

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a really helpful VSCode tool that can allow you to visualize what a merged class looks like. If you look at this branch in VSCode, you should see an option that says "View Code in Merge Editor" or something like that, and that view will be very helpful for solving these conflicts!

def initialize
@facilities = []
@facilities = [] # Array to store Facility objects
end

# Adds a facility to the DMV.
<<<<<<< HEAD
# @param facility [Facility] The facility object to be added.
=======
# @param facility [Facility] The facility to add.
>>>>>>> feature/vehicle-class
def add_facility(facility)
@facilities << facility
end

# Returns facilities that offer a specific service.
<<<<<<< HEAD
# @param service [String] The service to search for.
=======
# @param service [String] The service name to search for.
>>>>>>> feature/vehicle-class
# @return [Array<Facility>] List of facilities providing the service.
def facilities_offering_service(service)
@facilities.find do |facility|
facility.services.include?(service)
end
@facilities.select { |facility| facility.services.include?(service) }
end
end

16 changes: 12 additions & 4 deletions lib/dmv_data_service.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
require 'faraday'
require 'json'

# The DmvDataService class retrieves external data from an API.
class DmvDataService
# Loads data from a given URL
# @param source: String URL for the data source
# @return: Parsed JSON data
def load_data(source)
response = Faraday.get(source)
JSON.parse(response.body, symbolize_names: true)
end

# Retrieves Washington EV Registration data
def wa_ev_registrations
@wa_ev_registrations ||= load_data('https://data.wa.gov/resource/rpr4-cgyd.json')
load_data('https://data.wa.gov/resource/rpr4-cgyd.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expect you to need to update these instance variables. Did you have an issue with reading them from another class?

end

# Retrieves Colorado DMV Office Locations data
def co_dmv_office_locations
@co_dmv_office_locations ||= load_data('https://data.colorado.gov/resource/dsw3-mrn4.json')
load_data('https://data.colorado.gov/resource/dsw3-mrn4.json')
end

# Retrieves New York DMV Office Locations data
def ny_dmv_office_locations
@ny_dmv_office_locations ||= load_data('https://data.ny.gov/resource/9upz-c7xg.json')
load_data('https://data.ny.gov/resource/9upz-c7xg.json')
end

# Retrieves Missouri DMV Office Locations data
def mo_dmv_office_locations
@mo_dmv_office_locations ||= load_data('https://data.mo.gov/resource/835g-7keg.json')
load_data('https://data.mo.gov/resource/835g-7keg.json')
end
end
47 changes: 42 additions & 5 deletions lib/facility.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for this class --> you're still in the midst of a merge conflict here and will need to merge the code accordingly and then remove the merge conflict symbols

# Updated Facility class with initializer to accept a hash of details
class Facility
attr_reader :name, :address, :phone, :services

def initialize(name, address, phone)
@name = name
@address = address
@phone = phone
# Initialize with a hash containing the facility details
=======
require_relative 'vehicle'

class Facility
attr_reader :name, :address, :phone, :services, :registered_vehicles, :collected_fees

# Initializes a Facility with details and an empty services list
>>>>>>> feature/vehicle-class
def initialize(details)
@name = details[:name]
@address = details[:address]
@phone = details[:phone]
@services = []
<<<<<<< HEAD
end

def add_services(service)
# Add a service to the facility
def add_service(service)
@services << service
end
end

=======
@registered_vehicles = []
@collected_fees = 0
end

# Adds a service to the facility
def add_service(service)
@services << service
end

class Facility
attr_reader :name, :services

def initialize(name)
@name = name
@services = []
end

def add_service(service)
@services << service
end
end
>>>>>>> feature/vehicle-class
25 changes: 25 additions & 0 deletions lib/facility_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merge conflict should be a relatively easier merge fix, so I'd encourage you to use the VSCode merge editing tool with this one

=======

>>>>>>> feature/facility-class
require_relative 'facility'

# The FacilityFactory class creates Facility objects from external data sources.
class FacilityFactory
# Creates an array of Facility objects from external data.
# @param data [Array<Hash>] An array of facility details from the API.
# @return [Array<Facility>] An array of Facility objects.
def create_facilities(data)
data.map do |facility_data|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

Facility.new({
name: facility_data[:dmv_office],
address: "#{facility_data[:address_li]}, #{facility_data[:city]}",
phone: facility_data[:phone]
})
end
end
<<<<<<< HEAD
end
=======
end
>>>>>>> feature/facility-class
25 changes: 25 additions & 0 deletions lib/registrant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# The Registrant class represents a person who interacts with DMV services.
# A registrant can have a permit and progress to earning a license.
class Registrant
attr_reader :name, :age, :license_data

# Initializes the registrant with a name, age, and optional permit status.
# license_data is initialized to track written, road, and renewed license status.
def initialize(name, age, permit = false)
@name = name
@age = age
@permit = permit
@license_data = { written: false, license: false, renewed: false }
end

# Checks if the registrant has a permit.
def permit?
@permit
end

# Allows a registrant to earn a permit.
def earn_permit
@permit = true
end
end

109 changes: 95 additions & 14 deletions lib/vehicle.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,106 @@
require 'date'
require_relative 'vehicle'

<<<<<<< HEAD
<<<<<<< HEAD
# The Vehicle class represents a registered vehicle.
class Vehicle
attr_reader :vin,
:year,
:make,
:model,
:engine

def initialize(vehicle_details)
@vin = vehicle_details[:vin]
@year = vehicle_details[:year]
@make = vehicle_details[:make]
@model = vehicle_details[:model]
@engine = vehicle_details[:engine]
<<<<<<< HEAD
attr_reader :vin, :year, :make, :model, :engine, :registration_date, :plate_type
=======
attr_reader :vin, :year, :make, :model, :engine, :registration_date
>>>>>>> feature/facility-class

=======
# The Vehicle class represents a car, truck, or other registered vehicle.
class Vehicle
attr_reader :vin, :year, :make, :model, :engine, :registration_date, :plate_type

# Initializes a Vehicle object with attributes
>>>>>>> feature/vehicle-class
def initialize(details)
@vin = details[:vin]
@year = details[:year]
@make = details[:make]
@model = details[:model]
@engine = details[:engine]
<<<<<<< HEAD
<<<<<<< HEAD
@registration_date = nil
@plate_type = nil
end

# Registers the vehicle and determines the plate type.
=======
@registration_date = nil # Default: not registered
@plate_type = nil # Default: no plate type
end

# Registers the vehicle and assigns a plate type
>>>>>>> feature/vehicle-class
def register
@registration_date = Date.today
@plate_type = determine_plate_type
end

<<<<<<< HEAD
# Determines plate type.
def determine_plate_type
return :antique if antique?
return :ev if electric?
:regular
=======
@registration_date = nil # Default value
>>>>>>> feature/facility-class
end

# Check if the vehicle is antique
=======
# Determines the plate type: antique, electric, or regular
def determine_plate_type
if antique?
:antique
elsif electric?
:ev
else
:regular
end
end

# Determines if the vehicle is antique (older than 25 years)
>>>>>>> feature/vehicle-class
def antique?
Date.today.year - @year > 25
end

def electric_vehicle?
<<<<<<< HEAD
<<<<<<< HEAD
=======
# Determines if the vehicle is electric
>>>>>>> feature/vehicle-class
def electric?
@engine == :ev
=======
# Register the vehicle
def register
@registration_date = Date.today
>>>>>>> feature/facility-class
=======
# The VehicleFactory class creates Vehicle objects from external data sources.
class VehicleFactory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd want VehicleFactory to live in a separate file

# Creates an array of Vehicle objects from external data.
# @param data [Array<Hash>] An array of vehicle details from the API.
# @return [Array<Vehicle>] An array of Vehicle objects.
def create_vehicles(data)
data.map do |vehicle_data|
Vehicle.new({
vin: vehicle_data[:vin_1_10],
year: vehicle_data[:model_year].to_i,
make: vehicle_data[:make],
model: vehicle_data[:model],
engine: :ev # Since data is for EV registrations, set engine type to :ev
})
end
>>>>>>> feature/registrant-factories
end
end

19 changes: 19 additions & 0 deletions lib/vehicle_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative 'vehicle'

# The VehicleFactory class is responsible for creating Vehicle objects from external data.
class VehicleFactory
# Creates Vehicle objects from provided data
# @param data: Array of hashes containing vehicle details
# @return: Array of Vehicle objects
def create_vehicles(data)
data.map do |vehicle_data|
Vehicle.new({
vin: vehicle_data[:vin_1_10],
year: vehicle_data[:model_year].to_i,
make: vehicle_data[:make],
model: vehicle_data[:model],
engine: :ev # Default engine type to electric for external EV data
})
end
end
end
Loading