1
h01
CS24 W18
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 Tue 04/03 11:00AM Tue 04/10 11:00AM

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 three lowest scores (if you have zeros, those are the three 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. (2 pts) Name two benefits of procedural abstraction in writing code.
    2. (4 pts) Describe a technique for incorporating the principle of information hiding when describing a function's behaviour.
    3. (5 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. (2 pts) What kind of member of a class supports information hiding?
    5. (4 pts) What is the difference between a class and an object?
    6. (4 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 in the throttle when creating objects of that class. You don't need to provide an implementation of the new throttle ADT, just the class definition.
    7. (4 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. You do not have to implement the entire ADT, just the class definition.
    8. (50 pts) Complete the CS 16 final exam available at this link. Turn in the completed answer sheet during your lab section.