CS 163/164, Spring 2018
Lab 9 - Methods and Parameters
Tuesday, Feb. 20th or
Wednesday, Feb. 21st
Objectives of this Lab
- Setup for the Maze programming assignment,
- introduce you to declaring and calling methods, and
- show how method parameters and return values work.
Part of this lab is setting up for the P6 assignment, in which you control
a character in a maze. The assignment requires a variety of data files,
image files, and a graphical user interface class.
Before working on Lab 9, go to the link for the P6 assignment. With the
help of your TA, complete all of the Getting Started section of the assignment.
For this lab, we are starting by studying methods in the classes supplied by Java. You are already familiar with many of these methods. Create a project R9 and a class, and enter the answers to the following questions in comments in R9.java.
List the type of the return value and parameters to each of the following methods:
From the following calls, figure out what the return type and parameters might be:
int count = computeNumberOfLetters("Hello There!");
double percent = findRatio(0.567f, 1.234f, 2.568f, 5.678f, 9.235f);
char special = someMethod(s.substring(1, 8), Character.isUpperCase(c), Math.pow(2.0, 3));
String string = anotherMethod((int)'c', (int)'a', (char)78, (char)99, "Whatever");
Your TA will discuss the answer to the questions.
Show your completed P6 setup and your R9 comments to your TA for credit for the lab.