Sunday, 31 October 2010

Chapter 5 35-48


35
Implement the final changes discussed in the text in your own version of the program.

A:
Done it.
36
Add more word/response mappings into your application. You should copy some out of the solution provided and add some yourself.
A:
System.out.println("You might want to just change you computer, it seems to be at the peak of its life");
System.out.println("Sorry sir, but this is not a playground, you may want to use more formal language");
System.out.println("Your insulting, and you expect help from us?");
System.out.println("Do you really think it's my fault this is not working?");
System.out.println("Your computer seems to be disfunctional, I recommend you buy a new one.");
37
Sometimes two words (or variations of a word) are mapped to the same response. Deal with this by mapping synonyms or related expressions to the same string, so that you do not need multiple entries in the reponse map for the same response.
A:
Done it.
38
Identify multiple matching words in the user's input and respond with a more appropriate answer in that case.
A:
Done, I'm still unsure, however, of how many times a user should say the word in order for it to become the more detailed response. In all cases however, I set it to five.
39
When no word is recognized, use other words from the user's input to pick a well-fitting default response: for example words like "who","why, "how"
A:
Done it, I simply threw back a question at the user. For example, "Why is this?" would return the response I made, "Why shouldn't it?".
40
Use BlueJ's Generate Documentation function to generate documentation for your techSupport project.
Examine it. Is it accurate?
Is it complete?
Which parts are useful, which are not?
Can you find any errors in the documentation?
 A:
It's not so complete, because I haven't documented everything, but for the parts that do have a default message from Barnes and Kolling, it seems pretty detailed, and complete. I see the purpose of @param and @version @author now. I'm unable to find any errors however.
41
Find examaples of javadoc key symbols in the source code of the TechSupport project.
How do they influence the formatting of the documentation?
A:
If key symbols like @param, appear in the source code of a project they become categories in which the text following their appearance is the test that appears in the category.

42
Find out about and describe other javadoc key symbols.
One palce you can look is the online documentation of Sun Microsystems' java distribution. It contains a documnt called  javadoc - The Java API Documnentation Generator.
In this document the key symbols are called javadoc tags.
 A:
Although many tags appear, the essential ones in my opinion are:
@link which inserts a link to another file or project.
and @author which describes and includes a section on where the project has come from.
43
Properly document all classes in your version of the TechSupport project.
A:
Done it. I included @param where needed, as well as @return, which explain the parameters of each method and return where I explain the results of the method.
44
Create a BallDemo object and execute the drawDemo() and bounce() methods.
Then read the BallDemo source code.
Describe, in detail, how these methods work.
 A:
Essentially, this project, in both methods, creates a few objects that work together in that they move and wait for each other to move. For example, the rectangle moves, then lets the line be drawn, then moves again. This all happens extremely fast, and together creates a series of movements which combine.
45
Read the documentation of the Canvas class. Then answer the following questions in writing, including fragments of Java code.
How do you create a Canvas?
How do you make it visible?
How do you draw a line?
How can you erase something?
What is the difference between draw() and fill()?
What does wait do?
 A:
a) You initialize it with a title, and/or, and two measurements of width and height, and/or a background color. However, you can omit everything but the title, and start it as a default like that.
b) When you instantiate a Canvas object, the terminal will automatically appear.
c) Call the drawLine() method where two points must be given in order for it to calculate a slope.
d) Use the erase() method, but enter the shape's name if you want to only erase a given object.
e) draw() simply makes the shape visible on the canvas, but fill() fills up the shape with a certain color. For example you can have an "open" circle, and fill it up with the fill() method.
f) wait() makes the shape wait for a specified amount of seconds before continuing.
46
Experiment with Canvas operations by making changes to the drawDemo() method of BallDemo. Draw some more lines, shapes and text.
A:
Done it. There's a whole spectrum of possibilities, but I chose to make a rectangle and move it to +50 on x, make it wait, then move it +300 on x to make it sort of materialize, move, wait, then leave.
47
Draw a frame around the canvas by drawing a rectangle 20 pixels inside the window borders. Put this functionality into a method called drawFrame() in the BallDemo class.
A:
Done, I'm only worrying that maybe the shapes will remove the fill of the rectangle after we call the drawDemo method...
48
Improve your drawFrame() method to adapt automatically to the current canvas's size.
To do this, you need to find out how to make use of an object of class Dimension.
 A:
I'm having trouble getting this one to work, i'll confront you with it during the day.

No comments:

Post a Comment