6.7

Week 14 Set b

home work!

Programming Language ISL+

Due Date Wed at 9pm (Week 14)

Purpose To demonstrate once again mastery of data-driven design in context

Registration If you would like to turn in this extra-credit assignment, you must register via email to Becca M. by Wednesday 23 November 2016. The email must come from one partner and CC the other one so that both commit. Becca will simply ignore invalid emails.

Extra-Credit Exercise

Problem 1 of Week 11 Set b requested an addition of commands and chats to your chat client. Before proceeding, fix your solution in response to our feedback.

You are now ready to revise your client so it can communicate in two additional ways with the server. Here is the extension of the Command data definition:

; A Command is one of:

   

interpretation

. . .

   

. . .

; -- "STATUS"

   

status command

; -- (list "NAME" String)

   

name-change command

The server interprets these additional commands as follows:

When a client C ...

the server ...

. . .

. . .

sends "STATUS",

replies with a status message

sends (list "NAME" n),

broadcasts a name-change message

 

and uses n for the client from now on.

. . .

. . .

What this means for your client

These changes have consequences for the messages your client receives and the commands it sends. Your task is to adapt your client to this revised server.

Sending Commands You will have to adapt your conventions for entering Commands in the text field so that users can send code commands. You are free to choose whatever convention you want as long as it is explained in the purpose statement of your client program.

Receiving Messages Your client will now receive two additional kinds of Chats:

; A Chat is one of:

   

interpretation

. . .

   

. . .

; -- (list "STATUS" [Listof String])

   

status message

; -- (list "NAME" String String)

   

name-change message

The status message comes with the names of the currently logged-in users while a name-change message of the shape (list "NAME" real public) says that the user known as real will from now on send messages as public. But, we leave it up to you how you interpret these Chats within your client (canvas); just make sure that the purpose statement for your complete program (top of file) explains what you do.

Grading Here is the precise specification of the value of the problem.

; computing the problem-set portion of the final grade for an individual
 
(require 2htdp/abstraction)
 
(define-struct grade [points outof])
; Grade  = (make-grade Points Outof)
; Outof  = PositiveNumber
; Points = PositiveNumber,
;   possibly larger than the corresponding Outof due to 'local' extra credit
 
(define grades
  (list (make-grade 10 10)
        (make-grade  0 10)))
(define 100% 1.0)
(define 200% 2.0)
 
; [Listof Grade] [Maybe Grade] -> Grade
; how to deal with extra credit for the grade total
(check-expect (best-of grades (make-grade 10 10)) 200%)
(define (best-of grades extra-14b)
  (if (boolean? extra-14b)
      (normal-grades grades 0)
      (normal-grades grades (grade-points extra-14b))))
 
; [Listof Grade] PositiveNumber -> [List N Grade]
; drop the problem set with the worst impact on the student's grade
; ASSUME grades contains at least two elements
(check-expect (normal-grades grades 0) 100%)
(define (normal-grades grades extra-credit)
  (local ((define points  (+ extra-credit (foldr + 0 (map grade-points grades))))
          (define maximal (foldr + 0 (map grade-outof grades)))
          (define drop-one
            (for/list ((g grades))
              (/ (- points (grade-points g))
                 (- maximal (grade-outof g))))))
    (apply max drop-one)))
We will not answer any question regarding the value of this problem set.