CSE 11 Programming Assignment 5

Due Date: Monday, August 22, 10:00PM Pacific Time

Learning Goals

Collaboration

Different assignments in this course have different collaboration policies. On this assignment, you can collaborate with anyone in the course, including sharing code. In your submission, give credit to all students and course staff who helped you with this assignment by noting their name and how you used their ideas or work. Note that using someone’s work without giving credit to them is a violation of academic integrity.

You can get the starter code at

https://github.com/ucsd-cse11-su222/cse11-pa5-starter

Array Methods

In a file called ArrayExamples.java, write the following methods in a class called ArrayExamples. For each, write at least three tests (a test is a use of checkExpect) where each of the three has a different length of array used in the input.

Using Main and Command-line Arguments

Submission

All of your Java files you will upload to Gradescope as usual.

FAQ

  1. Can we use <some other library> in this PA instead of loops?
    • Try to use the things we learned most recently. That said, if you know something you want to try, that’s fine. Just be warned that it might be more work to not use the stuff we just learned
  2. I wrote test methods with the Tester, but ./run is telling me that no tests ran.
    • Tester methods have to start with “test” at the beginning! For example, boolean testAdd(Tester t) { …. }. In ArrayExamples.java, all tests should be in class ArrayExamples, not Pair.
  3. I failed some tests on Gradescope, but it is not showing me any error message, so I don’t know what is wrong.
    • We did something slightly different with this autograder. For each method we wrote several tests but only publicly show you some of their results in detail. The goal is to give you a nudge to think more about detailed tests you could write for your own methods. So you can see where you failed and all you know (for now) is that you should try testing and understanding those methods more.
  4. My earliest method’s tests on Gradescope are not passing.
    • Double check your understanding of compareTo method. Try using compareTo with longer strings and seeing the result. Does the method always return 0, -1, or 1?
  5. I am receiving an array index out of bounds error in Longest.java.
    • Unlike some of the previous method, you can not make the assumption that string argument(s) will be given. Hence, args[0] will throw the index out of bounds error. What is a possible way to check if any arguments are given?
  6. Help! I did the conditional checking and Longest.java is still throwing index out of bounds!