



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A laboratory assignment for computer science i (cis 201) students to create a java game named 'catnip'. Students will learn how to create a java class, use the keyboard in fang, work with variables, and write javadoc formatted comments. They will also learn about multi-line and end-of-line comments, import statements, and the setup and advance methods in fang. Students are expected to create a new directory, copy the catnip.java file, and start emacs to edit the file. They will also need to add variables, import statements, and compile the code.
Typology: Lab Reports
1 / 6
This page cannot be seen from the preview
Don't miss anything!
All Java programs are built using Java classes , and all Java classes have names. We normally name a class so that the name generally describes the purpose of the class. Each Java class defines a new Java type. We will describe the terms class and type in more detail as our course progreses. The name of a Java class must begin with an uppercase letter and must consist only of letters, digits, and underscores.
layout that defines the objects and behaviors necessary to carry out some specific defined activity
To define a Java class, you need to create a file with the same name as the class but ending with
into your current directory with the following command:
Again, don’t forget the dot!
so that the windows fit on the monitors in the classroom. You might be more productive if you’re able
with the first mouse button, and pull the window downward or upward to change the vertical size.
Programs should always contain comments. Comments are used to help others who read your code – or you, if you haven’t looked at the code for a long time – to understand what the program is about and how it is supposed to work. Comments don’t affect the way the program actually works, since comments are essentially ignored by the program compiler.
Java has two ways to include comments: multi-line comments, and end-of-line comments.
that line. End-of-line comments are typically much shorter than multi-line comments and normally appear along with program code instead of at the beginning of your program.
Now compile your code and notice that these errors have been fixed.
Show us that your code compiles correctly at this point.
FANG documentation. (You can also get to this documentation from our department homepage,
The documentation comes up in a window that has a big list of lots of things. We are interested in
Click on it. This provides the documentation generated from comments in that class – you might notice that the FANG documentation is pretty sparse, but this doesn’t mean that your documentation should be as bad.
assumed to be width 1.0 and height 1.0. The top-left corner of the canvas has coordinates
nates go from top to bottom.
screens per second****.
catnip moves from left to right across the screen. If it is “caught” by the cat, it’s a hit. If not, it’s a miss.
Checkpoint 2
Show us your running game at this point.
Changing the speed parameters
You can change the speeds of the cat, the cat sitter, and the catnip. Experiment with these values and see what happerns. What if you set the cat sitter speed to zero? What if you set the catnip speed to zero?
Checkpoint 3
Show us some of your changes.
Keeping track of the score
this variable? What should be its type?
Checkpoint 4
Show us your changes, and show us where the score is being displayed!