1
h01
CS24 W19
Name:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu section
Optional: name you wish to be called
if different from name above.
Optional: name of "homework buddy"
(leaving this blank signifies "I worked alone"

h01: Chapter 1.1, 2.1-2.2

ready? assigned due points
true Wed 01/09 02:00PM Mon 01/14 12:00PM

You may collaborate on this homework with AT MOST one person, an optional "homework buddy".

MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the lowest scores (if you have zeros, those are the lowest scores.)


Reading: Read Chapter 1.1, 2.1-2.2. If you don’t have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”.

    1. (5 pts) Name two benefits of procedural abstraction in writing code.
    2. (5 pts) Describe a technique for incorporating the principle of information hiding when describing a function's behaviour.
    3. (10 pts) Write the pre and post conditions for a function that takes as input two parameters: distance (in meters) and time (in seconds), and computes speed as output.
    4. (5 pts) Which access specifier should be used to hide member functions and variables from code outside of the class?
    5. (5 pts) What is the difference between a class and an object?
    6. (10 pts) Modify the definition of the throttle class on page 35, to create a new throttle ADT, which allows the user of the ADT to specify the number of shift levels when creating objects of that class. You don't need to provide an implementation of the new throttle ADT, just the class definition.
    7. (10 pts) Modify the definition of the throttle ADT on page 35, to create a new throttle ADT, which models a throttle as having a lever to control the flow of fuel (as before), and a light that indicates if the fuel flow is above or below a threshold. The light is green if the fuel flow is below 70%, and red otherwise. The new throttle ADT should have appropriate member functions to check on the status of the light. Implement the new throttle ADT
    8. (50 pts) Complete the CS 16 final exam available at this link. Turn in the completed answer sheet during your lab section.