11-13-2013

posted Nov 13, 2013, 8:33 AM by Samuel Konstantinovich   [ updated Nov 14, 2013, 5:32 AM ]
Todo:
  A)Announcement: If your partner for the game assignments is not a good fit, you should talk to me about splitting up. Otherwise you will do one last part with your partner.
  B)Go over the last HW.

Goal: Design tests for the myList class.

The myList class will have the following methods:

void add(int value)
//add to end of list

void add(int index, int value)
//add at a specific index

int get(int index)
//return the value at the index

int remove(int index)
//return the value at the index, and remove it

int set(int index, int value)
//change the value at the index to value and return the old value

int size()
//return the number of elements currently in the list.

1. How can we write several automated tests that will verify that our code works? (This was homework on Friday)
2. How can we partition writing our code so that we can run tests? (You cannot write one test for all features, you must test them as you write them)

Homework due Friday:

Write tests (in phases) for your myList class. You will disable parts 3-6 until the prior tests work, then add the parts as you write more working code.

//Phase 1
1. add(value)
2. get()
//Phase 2 
3. size()
4. set()
//Phase 3 
5. add(index,value)
6. remove(index)

Submit your test program on dropbox in the "PeriodX\A Common Class Folder" folder.
Name that file   ListTesterName
like:
ListTesterEstherKim.java
ListTesterBobMarley.java

Addendum:
1. What happens when you L.set(10,value) or L.get(10)  when L.size() is 5? 
  Array index out of bounds is OK! That is a useful error that people understand.

2. What happens when you add to the list and exceed the capacity?
  The list capacity should increase like we discussed on Friday.

3a. What happens when you insert to an index past the size() ?
     You should append to the end of the list.
3b. What happens when you insert to a negative index?
     You should have an index out of bounds error... 
Comments