Back Edit Import Questions Delete

2 How to Design Data

In Systematic Program Design

Questions

New Question Start Quiz
What is the main purpose of a data definition?
Multiple choice
Which chain best matches the design principle in the notes?
Multiple choice
When is an enumeration appropriate?
Multiple choice
Which type comment describes an inclusive integer interval from 1 through 32?
Multiple choice
What is the template shape for an atomic non-distinct type such as CityName is String?
Multiple choice
What makes an itemization different from a simple enumeration?
Multiple choice
How does cond choose an answer?
Multiple choice
Why might an itemization cond use (and (number? c) (<= 1 c) ...)?
Multiple choice
Why can the last numeric subclass sometimes be tested with only (number? c)?
Multiple choice
What does it mean that HtDF and HtDD are orthogonal?
Multiple choice
If LetterGrade has exactly "A", "B", and "C", how many main cond branches should its template have?
Multiple choice
What is the interpretation in a data definition for?
Multiple choice
A function consumes SeatNum defined as Integer[1,32]. Is 50 a legal input according to the data definition?
Multiple choice
Which statement correctly distinguishes purpose from interpretation?
Multiple choice
Why should tests for an itemization cover every subclass?
Multiple choice
Define a data definition named LetterGrade that represents exactly the three strings "A", "B", and "C". Include the type comment, an interpretation, and the template for a function that consumes a LetterGrade.
Short answer
Define a data definition named SeatNum for legal seat numbers from 1 through 32 inclusive. Include the type comment, an interpretation, and the basic template for a function that consumes a SeatNum.
Short answer
Consider this itemization: Status is one of "closed" or an Integer from 1 through 10 inclusive. Write a template for a function that consumes a Status. Make sure the numeric test cannot accidentally be applied to the string case.
Short answer
In your own words, explain the difference between a function purpose statement and the interpretation in a data definition.
Short answer
Suppose an itemization says a value is either Integer[0,10] or Integer[5,20]. What problem does the value 7 create? If a cond checks the first interval before the second, what will happen?
Short answer
A parking garage has levels numbered 1 through 8 inclusive. Define a data definition named LevelNum with a precise type comment, an interpretation, and the basic template for a function that consumes a LevelNum.
Short answer
TrafficLight is one of the strings "red", "yellow", or "green". Write the data definition and template. In the template, use placeholders for unfinished function behavior rather than accidentally calling the parameter as a function.
Short answer
A data definition says TemperatureRange is either Integer[-10,10] or Integer[5,30]. Explain why this is a problematic itemization. Then explain what happens to the value 7 if a cond checks the -10-to-10 case before the 5-to-30 case.
Short answer

Quiz Sessions

Session #9 Session #10 Session #11