-
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
Beverly Green - the_dmv #598
base: main
Are you sure you want to change the base?
Changes from all commits
d5cfce3
37d8a0f
e722895
8b9706f
620b5cf
fc100ea
ac10039
1640b54
0e11ed1
5f38139
94b2930
e161d88
876304c
ba39589
b56d3fb
87a1e1b
dfd5f50
ffc93b9
7d1a2e8
059e1d1
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 |
---|---|---|
|
@@ -29,6 +29,7 @@ GEM | |
PLATFORMS | ||
arm64-darwin-20 | ||
arm64-darwin-21 | ||
arm64-darwin-23 | ||
|
||
DEPENDENCIES | ||
faraday | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class DMVFacilities | ||
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 |
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 | ||
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. 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 |
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) | ||
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. Love this helper method! Just make sure that you are writing tests for any methods that you add 😉 |
||
@license_data[key] = true | ||
end | ||
end |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,4 @@ | |
expect(@dds.mo_dmv_office_locations.size).to be_an(Integer) | ||
end | ||
end | ||
end | ||
end |
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 |
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.
I think it might make more sense to call this class
DMVFactory
to match the Vehicle Factory naming convention