-
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
Joseph Bloom #603
base: main
Are you sure you want to change the base?
Joseph Bloom #603
Changes from all commits
a71e671
33eb057
4c50e16
ed95d41
e71198b
a186a9b
8bb800e
5ed6bc4
d1cd4be
4f7b779
dc95fb8
e351fe1
6b65c77
85e71a9
87ad2fb
c836229
a4f3a30
e1812b2
af0412d
c6ee681
80ab761
33cc813
5fd1b5a
3df417d
39c7909
9efc280
b2cd589
f630d9a
bcf42c3
e7245d8
30493a4
d070708
21e93be
5130b52
560c19e
6d547af
43e7557
39ae304
3790ac3
b049375
068c527
73efab8
9f23f63
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 | ||
universal-darwin-24 | ||
|
||
DEPENDENCIES | ||
faraday | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
class Dmv | ||
require 'pry' | ||
|
||
class Dmv | ||
attr_reader :facilities | ||
def initialize | ||
@facilities = [] | ||
end | ||
|
||
def add_facility(facility) | ||
@facilities << facility | ||
@facilities << facility | ||
end | ||
|
||
def facilities_offering_service(service) | ||
@facilities.find do |facility| | ||
@facilities.find_all do |facility| | ||
facility.services.include?(service) | ||
end | ||
end | ||
|
||
|
||
end | ||
#branch 3/333 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require './lib/facility' | ||
require './lib/dmv_data_service' | ||
|
||
|
||
class DmvFacilities | ||
attr_accessor :facilities | ||
def initialize | ||
@facilities = [] | ||
end | ||
|
||
def create_facilities(facility_details) | ||
facility_details.each do |facility| | ||
new_facility = Facility.new(facility) | ||
@facilities << new_facility | ||
end | ||
return @facilities | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,59 @@ | ||
class Facility | ||
attr_reader :name, :address, :phone, :services | ||
|
||
def initialize(name, address, phone) | ||
@name = name | ||
@address = address | ||
@phone = phone | ||
def initialize(facility_details) | ||
@name = facility_details[:name] || facility_details[:dmv_office] || facility_details[:office_name] | ||
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. Nice use of this OR logic 😉 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. Thank you B) |
||
@address = facility_details[:address] || facility_details[:address_li] || facility_details[:street_address_line_1] || facility_details[:address1] | ||
@phone = facility_details[:phone] || facility_details[:public_phone_number] | ||
@services = [] | ||
@registered_vehicles = [] | ||
@collected_fees = 0 | ||
end | ||
|
||
def add_services(service) | ||
def add_service(service) | ||
@services << service | ||
end | ||
|
||
def registered_vehicles | ||
@registered_vehicles | ||
end | ||
|
||
def collected_fees | ||
@collected_fees | ||
end | ||
|
||
def register_vehicle(vehicle) | ||
vehicle.registration_date = Date.today.strftime("%m/%d/%Y") | ||
if vehicle.antique? | ||
@collected_fees += 25 | ||
@registered_vehicles << vehicle | ||
elsif vehicle.engine == :ev | ||
@collected_fees += 200 | ||
@registered_vehicles << vehicle | ||
else | ||
@collected_fees += 100 | ||
@registered_vehicles << vehicle | ||
end | ||
end | ||
|
||
def administer_written_test(registrant) | ||
if @services.include?("Written Test") && registrant.permit? == true | ||
registrant.license_data[:written] = true | ||
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 definitely works, but it would be a little better if there was a method on the registrant class that managed this change. It could either be explicitly exposing 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. That makes sense! i thought it was a little weird that I was handling this from facility. |
||
end | ||
return registrant.license_data[:written] | ||
end | ||
|
||
def administer_road_test(registrant) | ||
if @services.include?("Road Test") && registrant.license_data[:written] == true | ||
registrant.license_data[:license] = true | ||
end | ||
return registrant.license_data[:license] | ||
end | ||
|
||
def renew_drivers_license(registrant) | ||
if @services.include?("Renew License") && registrant.license_data[:license] == true | ||
registrant.license_data[:renewed] = true | ||
end | ||
return registrant.license_data[:renewed] | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
|
||
class Registrant | ||
|
||
attr_reader :name, | ||
:age, | ||
: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 | ||
end | ||
|
||
|
||
def earn_permit | ||
@permit = true | ||
end | ||
end | ||
|
||
#branch 2! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require './lib/vehicle' | ||
require './lib/dmv_data_service' | ||
|
||
|
||
class VehicleFactory | ||
attr_accessor :cars | ||
def initialize | ||
@cars = [] | ||
end | ||
|
||
def create_vehicles(vehicle_details) | ||
vehicle_details.each do |vehicle| | ||
new_vehicle = Vehicle.new(vehicle) | ||
@cars << new_vehicle | ||
end | ||
return @cars | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require 'spec_helper' | ||
require 'pry' | ||
|
||
RSpec.describe DmvFacilities do | ||
before do | ||
@dmvfacilities = DmvFacilities.new | ||
@co_dmv_office_locations = DmvDataService.new.co_dmv_office_locations | ||
@ny_dmv_office_locations = DmvDataService.new.ny_dmv_office_locations | ||
@mo_dmv_office_locations = DmvDataService.new.mo_dmv_office_locations | ||
end | ||
|
||
describe "#initialize" do | ||
it 'can initialize' do | ||
expect(@dmvfacilities).to be_an_instance_of(DmvFacilities) | ||
end | ||
end | ||
|
||
describe "#create CO facilities" do | ||
it 'can create CO facilities and hold facility details' do | ||
@dmvfacilities.create_facilities(@co_dmv_office_locations) | ||
expect(@dmvfacilities.facilities.length).to eq(5) | ||
expect(@dmvfacilities.facilities[1].name).to eq("DMV Northeast Branch") | ||
expect(@dmvfacilities.facilities[1].phone).to eq("(720) 865-4600") | ||
expect(@dmvfacilities.facilities[1].address).to eq("4685 Peoria Street") | ||
end | ||
end | ||
|
||
describe "#create NY facilities" do | ||
it 'can create NY facilities and hold facility details' do | ||
@dmvfacilities.create_facilities(@ny_dmv_office_locations) | ||
expect(@dmvfacilities.facilities.length).to eq(173) | ||
expect(@dmvfacilities.facilities[0].name).to eq("LAKE PLACID") | ||
expect(@dmvfacilities.facilities[1].name).to eq("HUDSON") | ||
expect(@dmvfacilities.facilities[2].name).to eq("RIVERHEAD KIOSK") | ||
end | ||
end | ||
|
||
describe "#create MO facilities" do | ||
it 'can create MO facilities and hold facility details' do | ||
@dmvfacilities.create_facilities(@mo_dmv_office_locations) | ||
expect(@dmvfacilities.facilities.length).to eq(174) | ||
expect(@dmvfacilities.facilities[1].name).to eq("High Ridge") | ||
expect(@dmvfacilities.facilities[0].address).to eq("2009 Plaza Dr.") | ||
expect(@dmvfacilities.facilities[2].phone).to eq("(660) 665-0292") | ||
end | ||
end | ||
|
||
describe "#adds all facilities" do | ||
it "can add facilities from all states at once" do | ||
mo_count = @mo_dmv_office_locations.count | ||
ny_count = @ny_dmv_office_locations.count | ||
co_count = @co_dmv_office_locations.count | ||
|
||
@dmvfacilities.create_facilities(@mo_dmv_office_locations) | ||
expect(@dmvfacilities.facilities.length).to eq(mo_count) | ||
|
||
@dmvfacilities.create_facilities(@ny_dmv_office_locations) | ||
expect(@dmvfacilities.facilities.length).to eq(mo_count + ny_count) | ||
|
||
@dmvfacilities.create_facilities(@co_dmv_office_locations) | ||
expect(@dmvfacilities.facilities.length).to eq(mo_count + ny_count + co_count) | ||
|
||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
RSpec.describe Facility do | ||
before(:each) do | ||
@facility = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
@cruz = Vehicle.new({vin_1_10: '123456789abcdefgh', model_year: "2012", make: 'Chevrolet', model: 'Cruz', engine: :ice} ) | ||
@bolt = Vehicle.new({vin_1_10: '987654321abcdefgh', model_year: "2019", make: 'Chevrolet', model: 'Bolt', engine: :ev} ) | ||
@camaro = Vehicle.new({vin_1_10: '1a2b3c4d5e6f', model_year: "1969", make: 'Chevrolet', model: 'Camaro', engine: :ice} ) | ||
end | ||
describe '#initialize' do | ||
it 'can initialize' do | ||
|
@@ -23,4 +26,82 @@ | |
expect(@facility.services).to eq(['New Drivers License', 'Renew Drivers License', 'Vehicle Registration']) | ||
end | ||
end | ||
|
||
describe '#register vehicle' do | ||
it 'can register a vehicle' do | ||
@facility.register_vehicle(@cruz) | ||
expect(@facility.registered_vehicles).to eq([@cruz]) | ||
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. You also want to make sure that the registration date is set when this method is called! 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. Ah yes gotcha! Missed that! |
||
end | ||
end | ||
|
||
describe '#check registered vehicles' do | ||
it 'has an array of vehicles' do | ||
@facility.register_vehicle(@bolt) | ||
@facility.register_vehicle(@camaro) | ||
expect(@facility.registered_vehicles).to eq([@bolt, @camaro]) | ||
end | ||
end | ||
|
||
describe '#check fees' do | ||
it 'has a value of collected fees' do | ||
@facility.register_vehicle(@cruz) | ||
@facility.register_vehicle(@bolt) | ||
@facility.register_vehicle(@camaro) | ||
expect(@facility.collected_fees).to eq(325) | ||
end | ||
end | ||
|
||
describe "#administer_written_test" do | ||
it "sets written value to true in registrant license data" do | ||
registrant_1 = Registrant.new('Bruce', 18, true ) | ||
registrant_2 = Registrant.new('Penny', 15 ) | ||
registrant_3 = Registrant.new('Tucker', 15 ) | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
facility_2 = Facility.new({name: 'DMV Northeast Branch', address: '4685 Peoria Street Suite 101 Denver CO 80239', phone: '(720) 865-4600'}) | ||
|
||
facility_1.add_service('Written Test') | ||
facility_1.administer_written_test(registrant_1) | ||
|
||
expect(registrant_1.license_data[:written]).to eq(true) | ||
end | ||
end | ||
|
||
describe "#administer_road_test" do | ||
it "sets license value to true in registrant license data" do | ||
registrant_1 = Registrant.new('Bruce', 18, true ) | ||
registrant_2 = Registrant.new('Penny', 15 ) | ||
registrant_3 = Registrant.new('Tucker', 15 ) | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
facility_2 = Facility.new({name: 'DMV Northeast Branch', address: '4685 Peoria Street Suite 101 Denver CO 80239', phone: '(720) 865-4600'}) | ||
|
||
facility_1.add_service('Written Test') | ||
facility_1.add_service('Road Test') | ||
|
||
facility_1.administer_written_test(registrant_1) | ||
facility_1.administer_road_test(registrant_1) | ||
|
||
expect(registrant_1.license_data[:license]).to eq(true) | ||
end | ||
end | ||
|
||
describe "#renew_drivers_license" do | ||
it "sets renewed value to true in registrant license data" do | ||
registrant_1 = Registrant.new('Bruce', 18, true ) | ||
registrant_2 = Registrant.new('Penny', 15 ) | ||
registrant_3 = Registrant.new('Tucker', 15 ) | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
facility_2 = Facility.new({name: 'DMV Northeast Branch', address: '4685 Peoria Street Suite 101 Denver CO 80239', phone: '(720) 865-4600'}) | ||
|
||
facility_1.add_service('Written Test') | ||
facility_1.add_service('Road Test') | ||
facility_1.add_service('Renew License') | ||
|
||
facility_1.administer_written_test(registrant_1) | ||
facility_1.administer_road_test(registrant_1) | ||
facility_1.renew_drivers_license(registrant_1) | ||
expect(registrant_1.license_data[:renewed]).to eq(true) | ||
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 conventionThere 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 agree ^