CSE115 Lab 9 Spring 2016 DUE DATES:

advertisement
CSE115
Lab 9
Spring 2016
DUE DATES:
Tuesday recitations: 9:00 PM on 4/11
Wednesday recitations: 9:00 PM on 4/12
Thursday recitations: 9:00 PM on 4/13
Friday recitations: 9:00 PM on 4/14
Ready!
The purpose of this lab is primarily to give you practice reading code and understanding what it
does. This is a useful skill to have not just when you read code that other people wrote, but also
when you read code that you wrote more than a few days ago.
Set!
1.
2.
3.
4.
5.
Log in
Start Eclipse
Switch to the CVS Repository Exploring perspective
Check out the CSE115-Lab9 project from the Labs repository
Switch to the Java perspective
Go!
We are again providing some JUnit tests. You may NOT change the JUnit tests.
We are also giving you the definitions of several methods, in the code.Methods class. You may NOT
change the method of this class.
Finally, we are giving you method in the code.Inputs class. Define each method so that it returns a
value as described. For example, here's the inputForMethod_1_A method:
// Study the definition of the method
//
method_1
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_1,
// causes method_1 to return the value 20.
public ArrayList<String> inputForMethod_1_A() {
return null;
}
Following these directions, study the definition of method_1 from the Methods class,
public int method_1(ArrayList<String> list) {
if (list == null || list.size() < 3) { return -1; }
int total = 0;
for (int i=0; i<list.size(); i=i+1) {
if (list.get(i) != null) {
CSE115
Lab 9
Spring 2016
total = total + list.get(i).length();
}
}
return total;
}
Then, fill in the body of the inputForMethod_1_A method so that if this code is run:
Methods m = new Methods();
ArrayList<String> list = new Inputs().inputForMethod_1_A();
then m.method_1(list) returns the value 20. In other words, you need to find one possible input
value X for which m.method_1(X) returns 20.
Do the same for all the methods in Input.
Submitting your project to Web-CAT
Make sure you submit your work on time; due dates are listed at the beginning of this lab
description. This lab will be automatically graded by Web-CAT. You may submit as many times as
you wish. Your last submission is the one that counts (so consider carefully whether you want to
make any late submissions, as the late penalty is 20 points per day or portion thereof late).
Pay attention to the output produced by Web-CAT. If your submission scores 100 (without any
early submission bonus you might be entitled to) you're all set. If your submission does NOT score
100, fix the problem and resubmit. Prior to the submissions deadline we expect that you will
continue working until your submission scores 100.
Download