Question 1 Question 2 Question 3

Report 10 Downloads 364 Views
C our ses

Jua n Luis Her r er a C or t ijo 

Introduction to Systematic Program Design - Part 1

Signature Track

by Gregor Kiczales

Feedback — Quiz 3

Report a problem

Thank you. Your submission for this quiz was received. Announcements Course Information COURSE MODULES

You submitted this quiz on Sun 23 Jun 2013 12:54 PM CEST (UTC +0200). You got a score of 11.00 out of 11.00.

IMPORTANT: for dinner-starter.rkt homework problem, we recently renamed the data definition Dinner to DinnerOrder, and the function dinnerchoice to dinner-order-to-msg. Your solution should not be affected by this change, but please be sure to use DinnerOrder and dinner-

Week 1 - Primitives

order-to-msg.

Week 2 - HtDF

You may use your solutions from week 3 homework problems to answer the following questions.

Week 3 - HtDD

Questions 1-4 are based on breakfast-starter.rkt, questions 5-10 are based on dinner-starter.rkt, and questions 11-13 are based on directionstarter.rkt.

Week 4 - HtDW Week 5 - Arbitrary Sized Data

Question 1 REFERENCE

Design Recipes Language Style Rules HtDP/2e Book  ADDITIONAL RESOURCES

To Do Well in This Course Discussion Forums All Problems

NOTE: this question is not for marks. What form of data definition did you use to represent OatmealTemp? Your Answer

Score

Explanation

0.00

Interval is used when the form of the information to be represented is numbers within a certain range.

Simple atomic data Enumeration Itemization Interval



Total

0.00 / 0.00

Question Explanation

All Lectures

The answer is itemization.

All Lectures (Classic)

Itemization is used when the form of the information to be represented is comprised of 2 or more subclasses, at least one of which is not a distinct data item.

All Quizzes

For OatmealTemp, the intervals are the non-distinct data items, and the perfect temperature is the distinct data item.

All Peer Assessments Surveys Course Wiki 

Question 2 What form of data definition did you use to represent Adjustment?

Join a Meetup   Help Articles  Course Materials Errors  Platform Feedback

Your Answer

Score

Explanation

Simple atomic data Interval Itemization Enumeration



Total

1.00 1.00 / 1.00

Question Explanation Enumerations are used when the form of the information to be represented consists of a fixed number of distinct values. Adjustment consists of 3 distinct values: "turn left", "turn right", and "leave as is".

Question 3 What is the correct signature for oatmeal-temp-to-adjustment function? You entered: OatmealTemp->Adjustment

Your Answer

Score

Explanation

OatmealTemp->Adjustment

1.00



Total

1.00 / 1.00

Question Explanation The correct signature is OatmealTemp -> Adjustment since the function consumes the current oatmeal temperature, and produces the required stove adjustment.

Question 4 Which template did you use to design oatmeal-temp-to-adjustment? Your Answer

Score

The template for OatmealTemp



Explanation

1.00

I didn't use a template I designed a new template for this function The template for Adjustment Total

1.00 / 1.00

Question Explanation According to the signature, the function consumes OatmealTemp, so the template used to design oatmeal-temp-to-adjustment should be the template for OatmealTemp. The key thing to remember is that functions use the templates of the data they consume.

Question 5 What form of data definition did you use to represent DinnerOrder? Your Answer

Score

Explanation

Simple atomic data Interval Itemization Enumeration



Total

1.00 1.00 / 1.00

Question Explanation Enumeration is used when the form of the information to be represented consists of a fixed number of distinct values. An example of the distinct values used here would be false, "Chicken", and "Pasta".

Question 6 How many subclasses did you have for DinnerOrder data definition? [Enter a number] You entered: 3

Your Answer 3

Score 

Total

Explanation

1.00 1.00 / 1.00

Question Explanation We need 3 subclasses: 2 to represent each meal option, and 1 to represent no meal option.

Question 7 NOTE: this question is not for marks. Consider the following types comment for DinnerOrder (which might be slightly different from what you had): ;; DinnerOrder is one of: ;;

- "Chicken"

;;

- "Pasta"

;;

- false

;; interp. "Chicken" means the passenger wants chicken, "Pasta" means the passenger wants pasta, ;;

false means the passenger does not want dinner.

Based on the types comment above, what is wrong with the following template? [choose all that apply] (define (fn-for-dinner-order d) (cond [(string=? d "Chicken") (...)] [(string=? d "Pasta")

(...)]

[else (...)]))

Your Answer

Score

The guard string? is missing from the first case.



0.00

The guard false? is missing from the first case.



0.00

The guard string? is missing from the second case.



0.00

The guard false? is missing from the second case.



0.00

There is nothing wrong with this template.



0.00

Total

Explanation

0.00 / 0.00

Question Explanation The correct answers are "The guard string? is missing from the first case" and "The guard string? is missing from the second case." We must have guards for the first two cases to ensure that the parameter d is a string before we compare it to "Chicken" or "Pasta".

Question 8 What is the correct signature for dinner-order-to-msg function? You entered: DinnerOrder->String

Your Answer DinnerOrder->String

Score 

Total

Explanation

1.00 1.00 / 1.00

Question Explanation DinnerOrder -> String is correct because dinner-order-to-msg consumes a dinner option and produces a message explaining what the passenger ordered. NOTE: we also accepted Dinner -> String as an answer so that those who used the old version of dinner-starter.rkt are not affected.

Question 9 The following are possible purpose statements for dinner-order-to-msg. Choose the best one. Your Answer

Score

Explanation

;; consume string and produce dinner choice 

;; produce message to describe what passenger ordered

1.00

;; produce order ;; consume dinner choice and produce string Total

1.00 / 1.00

Question Explanation A purpose statement should be a one-line statement that says more than the signature, and enough to clearly describe what the function does.

Question 10 Choose all correct stubs for dinner-order-to-msg. Your Answer

Score

(define (dinner-order-to-msg d) d)



0.25

(define (dinner-order-to-msg d) "")



0.25

(define (dinner-order-to-msg d) 0)



0.25

Explanation



(define (dinner-order-to-msg d) "0") Total

0.25 1.00 / 1.00

Question Explanation A stub is a function definition that has the correct function name, the correct number of parameters, and produces a dummy result of the correct type. The correct type in this case is String.

Question 11 What signature did you use for left function? You entered: Direction->Direction

Your Answer

Score

Direction->Direction

Explanation

1.00



Total

1.00 / 1.00

Question Explanation Since the function consumes a direction and produces a direction, the signature should be: ;; Direction -> Direction

Question 12 Choose all correct stubs for left. Your Answer

Score

Explanation "" is not of type Direction.

(define (left d) "")



0.25

(define (left d) "E")



0.25

(define (left d) "SE")



0.25

(define (left d) "N")



0.25

Total

"SE" is not of type Direction.

1.00 / 1.00

Question Explanation Remember, the stub should produce a dummy result of the correct type. In this case the correct type is Direction.

Question 13 What was the minimum number of tests you needed for left? [Enter a number] You entered: 4

Your Answer 4

Score 

Total

Explanation

1.00 1.00 / 1.00

Question Explanation We need at least as many tests as there are cases in the enumeration (in this case 4).

Question 14 Since your quiz grade and feedback will be given to you as soon as you submit this quiz, it is important that you answer this additional question before you proceed:

I promise that I will not post answers to this quiz before Sunday June 23, 11:00 pm. Your Answer Yes

Score 

0.00

Explanation

No

MathJax no longer loads a default configuration file; you must specify such files explicitly. This page seems to use the older default config/MathJax.js file, and Total so needs to be updated. This is explained further at

http://www.mathjax.org/help/configuration

Loading [MathJax]/extensions/MathMenu.js

x

0.00 / 0.00