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

Beverly Green - the_dmv #598

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d5cfce3
All tests passing through iteration 1 requirements
bevgreen Dec 14, 2024
37d8a0f
Merge pull request #1 from bevgreen/registrant_feature
bevgreen Dec 14, 2024
e722895
Halfway through iteration 2 testing and methods
bevgreen Dec 14, 2024
8b9706f
27 tests passing for facility_1 features
bevgreen Dec 14, 2024
620b5cf
Finished Vehicle Registration feature for facility class
bevgreen Dec 14, 2024
fc100ea
Merge pull request #2 from bevgreen/functionality_feature_for_facilit…
bevgreen Dec 15, 2024
ac10039
Written test rspec tests all passing
bevgreen Dec 15, 2024
1640b54
Merge pull request #3 from bevgreen/drivers_license_feature
bevgreen Dec 15, 2024
0e11ed1
Driver's license tests all passing
bevgreen Dec 15, 2024
5f38139
Written, road, and renew license tests all passing
bevgreen Dec 15, 2024
94b2930
Merge pull request #4 from bevgreen/drivers_license_feature
bevgreen Dec 15, 2024
e161d88
Rspec tests for vehicle factory passing
bevgreen Dec 15, 2024
876304c
Merge pull request #5 from bevgreen/dmv_dataset
bevgreen Dec 15, 2024
ba39589
All tests for co_dmv_locations passing
bevgreen Dec 16, 2024
b56d3fb
All rspec tests passing through iteration 3 with all state datasets
bevgreen Dec 17, 2024
87a1e1b
Iteration 3 complete
bevgreen Dec 17, 2024
dfd5f50
All tests passing for Iteration 3
bevgreen Dec 17, 2024
ffc93b9
Merge pull request #6 from bevgreen/dmv_state_facility_datasets
bevgreen Dec 17, 2024
7d1a2e8
Refactoring code lines and organization
bevgreen Dec 17, 2024
059e1d1
final refactoring finished
bevgreen Dec 17, 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
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GEM
PLATFORMS
arm64-darwin-20
arm64-darwin-21
arm64-darwin-23

DEPENDENCIES
faraday
Expand Down
4 changes: 3 additions & 1 deletion lib/dmv.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Dmv
attr_reader :facilities

def initialize
@facilities = []
Expand All @@ -9,8 +10,9 @@ def add_facility(facility)
end

def facilities_offering_service(service)
@facilities.find do |facility|
@facilities.find_all do |facility|
facility.services.include?(service)
end
end

end
19 changes: 19 additions & 0 deletions lib/dmv_facilities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class DMVFacilities

Choose a reason for hiding this comment

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

I think it might make more sense to call this class DMVFactory to match the Vehicle Factory naming convention

attr_reader :facilities

def initialize
@facilities = []
end

def create_facilities(facility_data)
@facilities = []
facility_data.each do |facility|
new_facility = Facility.new({
:name => "#{facility[:dmv_office]}#{facility[:office_name]}#{facility[:name]}",
:address => "#{facility[:address_li]}#{facility[:street_address_line_1]}#{facility[:address1]} #{facility[:city]} #{facility[:state]} #{facility[:zip_code]}#{facility[:zipcode]}",
:phone => "#{facility[:phone]}#{facility[:public_phone_number]}"
})
@facilities << new_facility
end
end
end
71 changes: 65 additions & 6 deletions lib/facility.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,73 @@
class Facility
attr_reader :name, :address, :phone, :services
attr_reader :name,
:address,
:phone,
:services,
:registered_vehicles,
:collected_fees

def initialize(name, address, phone)
@name = name
@address = address
@phone = phone
def initialize(facility_details)
@name = facility_details[:name]
@address = facility_details[:address]
@phone = facility_details[:phone]
@services = []
@registered_vehicles = []
@collected_fees = 0
end

def add_services(service)
def add_service(service)
@services << service
end

def register_vehicle(vehicle)

if @services.include?('Vehicle Registration')
@registered_vehicles << vehicle

Choose a reason for hiding this comment

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

When a vehicle is registered, you probably also want to call the registration method on the vehicle so that the plate type is set and the registration date is updated!

end

end

def collect_fee(vehicle)

if vehicle.year < 1999
@collected_fees += 25
elsif vehicle.engine == :ev
@collected_fees += 200
else
@collected_fees += 100
end

end

def administer_written_test(registrant)

if @services.include?('Written Test') && registrant.permit? == true && registrant.age >= 16
registrant.change_license_data(:written)
true
else
return false
end

end

def administer_road_test(registrant)

if @services.include?('Road Test') && registrant.age >= 16 && registrant.license_data[:written] == true
registrant.change_license_data(:license)
true
else
return false
end

end

def renew_drviers_license(registrant)
if @services.include?('Renew License') && registrant.license_data[:written] == true && registrant.license_data[:license] == true
registrant.change_license_data(:renewed)
true
else
return false
end
end

end
29 changes: 29 additions & 0 deletions lib/registrant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'pry'

class Registrant
attr_reader :name,
:age,
:permit,
:license_data

def initialize(name, age, permit = false)
@name = name
@age = age
@permit = permit
@license_data ={:written =>false,
:license =>false,
:renewed =>false}
end

def permit?
@permit = permit
end

def earn_permit
@permit = true
end

def change_license_data(key)

Choose a reason for hiding this comment

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

Love this helper method! Just make sure that you are writing tests for any methods that you add 😉

@license_data[key] = true
end
end
20 changes: 19 additions & 1 deletion lib/vehicle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ class Vehicle
:year,
:make,
:model,
:engine
:engine,
:registration_date,
:plate_type


def initialize(vehicle_details)
@vin = vehicle_details[:vin]
@year = vehicle_details[:year]
@make = vehicle_details[:make]
@model = vehicle_details[:model]
@engine = vehicle_details[:engine]
@plate_type = plate_type
end

def antique?
Expand All @@ -22,4 +26,18 @@ def antique?
def electric_vehicle?
@engine == :ev
end

def register
@registration_date = Date.today

if antique?
@plate_type = :antique
elsif electric_vehicle?
@plate_type = :ev
else
@plate_type = :regular
end

end

end
22 changes: 22 additions & 0 deletions lib/vehicle_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class VehicleFactory
attr_reader :created_vehicles

def initialize
@created_vehicles = []
end

def create_vehicles(vehicle_data)
@created_vehicles = []
vehicle_data.each do |vehicle|
new_vehicle = Vehicle.new ({
:vin => vehicle[:vin_1_10],
:year => vehicle[:model_year],
:make => vehicle[:make],
:model => vehicle[:model],
:engine => :ev
})
@created_vehicles << new_vehicle
end
end

end
2 changes: 1 addition & 1 deletion spec/dmv_data_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
expect(@dds.mo_dmv_office_locations.size).to be_an(Integer)
end
end
end
end
45 changes: 45 additions & 0 deletions spec/dmv_facilities_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'spec_helper'

RSpec.describe DMVFacilities do

before(:each) do
@facility = DMVFacilities.new
end

describe '#initialize' do
it 'checks DMVFacilities class exists' do
expect(@facility).to be_a(DMVFacilities)
end
end

describe '#creates colorado facilities' do
it 'can create colorado facilities' do
co_dmv_office_locations = DmvDataService.new.co_dmv_office_locations
@facility.create_facilities(co_dmv_office_locations)
expect(@facility.facilities[0].name).to eq('DMV Tremont Branch')
expect(@facility.facilities[0].address).to eq('2855 Tremont Place Denver CO ')
expect(@facility.facilities[0].phone).to eq('(720) 865-4600')
end
end

describe '#creates new york facilities' do
it 'can create new york facilities' do
ny_dmv_office_locations = DmvDataService.new.ny_dmv_office_locations
@facility.create_facilities(ny_dmv_office_locations)
expect(@facility.facilities[1].name).to eq('HUDSON')
expect(@facility.facilities[1].address).to eq("560 WARREN STREET HUDSON NY 12534")
expect(@facility.facilities[1].phone).to eq('5188283350')
end
end

describe '#creates missouri facilities' do
it 'can create missouri facilities' do
mo_dmv_office_locations = DmvDataService.new.mo_dmv_office_locations
@facility.create_facilities(mo_dmv_office_locations)
expect(@facility.facilities[0].name).to eq('Harrisonville')
expect(@facility.facilities[0].address).to eq("2009 Plaza Dr. Harrisonville MO 64701")
expect(@facility.facilities[0].phone).to eq('(816) 884-4133')
end
end

end
Loading