-
Notifications
You must be signed in to change notification settings - Fork 257
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
base: main
Are you sure you want to change the base?
Changes from all commits
ff314fa
ad18eb8
e58fe59
acf20f8
fa6cf80
99fbd6e
054cf2b
02e805d
57796be
cb4bc29
e472486
f5344b6
bfb44be
ecebd20
fa4dec0
e72178e
f429a6d
8ac50ac
aa9853f
d0a63c6
8dd63fd
15bdb1e
6078480
7f805f4
4e29f79
1d7655c
e6c34b7
4d15741
a512de3
d5580c6
4489d3b
a2e2fcf
7f21c63
30f551d
27bcbc4
641cb90
92d1838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
.DS_Store |
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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,40 @@ | ||
<<<<<<< HEAD | ||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,51 @@ | ||
<<<<<<< HEAD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<<<<<<< HEAD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
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 | ||
|
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
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 |
There was a problem hiding this comment.
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.