R 1.
What is the difference between a simple data type and a complex data type?
Chapter ExercisesReview QuestionsR 1.
What is the difference between a simple data type and a complex data type?R 2.
Give an example of procedural abstraction and an example of data abstraction.R 3.
What is an abstract data type?R 4.
What are some of the advantages to defining and using abstract data types?R 5.
What is information hiding and why is it used?R 6.
List the four categories into which the operations of an ADT can be divided.R 7.
What is a precondition and what is a postcondition?ExercisesE 1.
Complete the partial implementation of the Time class by implementing the remaining operations: add , and subtract .E 2.
The definition of the Time ADT indicates that the arguments for creating a Time object must be specified within a given range. Modify the Time constructor from the program listing in section 1.6 Representing a Time Value to correctly verify the preconditions.E 3.
Modify the Time constructor to make each of the three arguments optional, with an initial value of zero. When no argument is supplied to the constructor, the time should be initialized to 1.E 4.
Complete the partial implementation of the LineSegment class by implementing the remaining operations: isHorizontal , isParallel , and midpoint .E 5.
Add additional operations to the LineSegment class:
Programming ProjectsP 1.
A click counter is a small hand-held device that contains a push button and a count display. To increment the counter, the button is pushed and the new count shows in the display. Clicker counters also contain a button that can be pressed to reset the counter to zero. Design and implement the Counter ADT that functions as a hand-held clicker.P 2.
A cone is a three-dimensional geometric shape that consists of a circular base and a vertex. The non-base surface of the cone tapers smoothly from the base to the vertex. A cone is defined by its radius and height.
Provide a complete implementation for the Cone ADT. P 3.
The use of the Student File Reader ADT makes it easy to extract student records from a text file no matter the format used to store the data. Implement a new version of the ADT to extract the data from a text file in which each record is stored on a separate line and the individual fields are separated by commas. For example, the following illustrates the format of a sample file containing three student records:
10015, John, Smith, 2, 3.01 10334, Jane, Roberts, 4, 3.81 10208, Patrick, Green, 1, 3.95 P 4.
In the chapter, we defined and implemented the Student File Reader ADT for extracting student records from an external source. We can define and use a similar ADT for output.
P 5.
Define and implement an ADT that can be used to represent a date in the Gregorian calendar for any date since November 24, 4713 BC.P 6.
Python provides a numeric class for working with floating-point values. But not all real numbers can be represented precisely on a computer since they are stored as binary values. In applications where the precision of real numbers is important, we can use rational numbers or fractions to store exact values. A fraction, such as , consists of two parts, both of which are integers. The top value, which can be any integer value, is known as the numerator. The bottom value, which must be greater than zero, is known as the denominator.
|