CSC 212: Programming with Data Structures

Homework 1: Conversation

Due: Wednesday, Feb. 3, 11:59pm

Credit for this assignment: Nick Howe


Outline

The purpose of this assignment is to review the programming techniques you learned in CSC 111 (or its equivalent), while beginning your introduction to Java. This assignment should not require any new programming concepts, but the Java syntax and compiler will be new.

For the main part of the assignment, you will write in Java a program similar to those you might have written in CSC 111. (In fact, this project is based on an assignment given in that course by Judy Franklin.) Your program will carry on a simple conversation with the user.

What to submit (rsubmit hw1 ...):

  • The Java file Conversation.java

  • A typescript file with the output of your program (see Lab 1)

  • A written reflection of the assignment, called readme.txt, where you consider and describe what you have learned from the assignment, any areas where you had trouble, comments, questions, suggestions (more details below).

Program: Conversation

The program you will write is a simple chatbot, a form originally popularized by the program called Eliza (very interesting history!)

It will ask the user to choose a number of rounds of conversation in advance. Then it will take turns printing messages to the user and accepting responses until the specified number of rounds are complete. Finally it will print a transcript of the entire conversation.

If at any point the user's input contains words that can be mirrored ("I" <-> "you" for example) then the computer's next response will be a mirrored version of the previous statement. Otherwise it will select from a set of canned phrases. Below is one sample conversation, with the user's input in red.



$ java Conversation  
How many rounds?  2  
Hi there!  What's on your mind? 
I'm thinking about clouds. 
You're thinking about clouds? 
Yes, but nothing very profound.  
Mmm-hm.
See ya!

TRANSCRIPT:
Hi there!  What's on your mind?
I'm thinking about clouds.
You're thinking about clouds?
Yes, but nothing very profound.
Mmm-hm.
See ya!

Follow this link for a more detailed description of what your program should do.


Hints and Extensions

  • Start early on this assignment so as to give yourself plenty of time. Although you may have written a similar program before, many things are different with Java.

  • For this assignment, you will not be required to catch exceptions that might be generated by the user entering unexpected input (such as something non-numeric for the number of conversation rounds). However, you are welcome to work on this as an extension. You also shouldn't worry yet about creating multiple classes; a single class with static fields and methods will do.

  • Feel free to improve and embelish your chatbot to include more interesting responses!

  • Because Java has an extensive web presence, you may be able to find code on the web related to this and other assignments. Resist the temptation to copy from these sources! Code taken from the web will not necessarily meet the requirements of this assignment, even if it solves the same general problem. Furthermore, representing someone else's work as your own is a violation of the Honor Code. (That said, looking at loosely related examples for ideas and general concepts is acceptable, so long as you then proceed to write the program on your own.)


Reflections

For this assignment, the reflection should describe the differences between Java and any previous programming experience (such as Python) you noticed while completing the assignment. What are your initial impressions of Java? Can you draw any conclusion about programming in general from the similarities or the differences between languages? You may also use the reflection as a means of expressing to me parts of the assignment that you found difficult, did not complete, etc. Do not fear that your grade will be lowered because you tell me that something is unclear to you; in grading, I will rely only on the evidence of the programs and typescript you submit. The reflection serves simultaneously as a means of self-improvement for the student, a form of feedback for the professor, and a way for the class to share ideas as a group.

I will post more about the self-reflections later on.


Assessment

Your grade on this homework is based on several factors. Most important is completeness. A program is considered complete if it compiles and executes more or less as described, is documented with a readable typescript, and includes adequate reflection. Programs turned in without a typescript or readme will not receive full credit. You have to submit all the files before the deadline. (An automated utility will collect the submissions at the deadline. Late submissions will therefore not be collected or graded.) Adherence to the style and documentation standards is another factor. Please follow the Javadoc style rules as described in class. Finally, I will evaluate your code for coherence, organization, and clarity.