For this activity you will implement a Ruby class and its methods used by the Department of Motor Vehicles (DMV) to schedule service for customers. When customers arrive at the DMV they are given a priority and a ticket number. The priority, from highest to lowest, is a letter 'A', 'B', or 'C'. The ticket numbers are generated sequentially starting at 1.
Customers are put at the tail end of a list associated with their priority; in our case, there is a Hashmap where the line ( 'A', 'B', or 'C') is the key and the value is an array which contatins the customer ticket numbers.
Create a directory named exactly DMV at the top level of your directory.
Download the file dmv.zip into this directory, extract all the files, and remove the downloaded dmv.zip.
You should see the following files in the directory; if you do not, immediately ask for help from your instructor.
dmv_schedule.rb and test_dmv_schedule.rbRun the following command:
> ruby test_dmv_schedule.rb
17 unit tests will be executed, and most will fail. However, if you see the following summary on the last line:
17 tests, 17 assertions, 16 failures, 0 errors, 0 skipsthen you have successfully downloaded and extracted the files.
At this point you should add, commit, and
push these files so that you are guaranteed to receive some credit!
Skeleton method implementations (which you are to complete) are in dmv_schedule.rb; each method has a preceding comment stating what the method does. The unit tests for the module are in test_dmv_schedule.rb
Methods exist to:
Initialize the Hash for each type of line (priority: A,B,C) and their associated line(array) of customers:
initialize()
Return the number of customers
in the line for a specified priority.
customer_count(priority)
Return the total number of customers
in all lines.
customer_count_all()
Add a new customer with a given priority
and ticket_number
and place them at the end of the appropriate line
new_customer(priority, ticket_number)
Return the ticket_number
of the customer at
the head of the line for a specified priority. The customer is removed from the line as a result of this operation. If the line is empty, return zero (0).
serve_customer(priority)
Return the ticket_number
of the customer at
the head of the line for a highest priority
that has any customers. The customer is removed from the line as a result of this operation. If all lines are empty, return zero (0).
serve_highest_priority_customer()
Suggested order of implementation (you may select any order that makes sense to you):
initialize
get_line
customer_count
customer_count_all
next_ticket
new_customer
serve_customer
serve_highest_priority_customer
DO NOT PUSH ANY CODE THAT DOES NOT
COMPILE OR THAT TERMINATES ABNORMALLY!
See Grading below.
There are 17 unit tests incorporating 56 assertions.
Each unit test is worth 5 points for a possible total of 85 points.
The remaining 15 points will be awarded for the quality of your solution:
There is a 10% penalty for naming your directory anything other than DMV or for changing the names of any of the files that are part of the distribution.
For the record, if you do nothing other than add, commit, and push the skeleton code from the correct directory your grade will be 27.
>ruby test_dmv_schedule.rb
Run options:
# Running tests:
.................
Finished tests in 0.010404s, 1633.9750 tests/s, 5382.5059 assertions/s.
17 tests, 56 assertions, 0 failures, 0 errors, 0 skips