Lesson 3
Extra Practice 3-2, Task 3
Step e. Add a method addEmployees that adds multiple employees
Lesson 4
Extra Practice 3-2: Equals method
- Add an equals method to the employee class
- Use employee id to test equality
- Make sure that it takes into account null values and references to other classes being passed in
- You can use ALT+INSERT in NetBeans to insert a sample equals method
- Test and correct until the code succeeds
- Modify the equality test to use the social security number
- Test and correct until the code runs correctly
Lesson 5
Extra Practice: Deck
- Start from the Deck lab from Java Funcamentals
- Replace the CardNames and CardValues arrays with enums Suit and Face
- Replace the decksize (52) with a number calculated from the available enums
- hint: using the values() method on your enum, returns an array of all values
- Test and correct the code until the program runs correctly
- Extend the Suit enums with the corresponding unicode characters
SPADES('\u2660'),CLUBS('\u2663'),DIAMONDS('\u2666'),HEARTS('\u2665');
- Extend the Face enum with numbers/names
ACE("Ace"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), SIX("6"),SEVEN("7"), EIGHT("8"), NINE("9"), TEN("10"), JACK("Jack"), QUEEN("Queen"), KING("King");
- Modify the code to display the cards using the new data
- Test and correct the code until the program runs correctly
Lesson 7
Extra Practice: Couple
- Write a generic class Couple<S,T> that stores two values each with its own generic type
- Write a constructor without parameters and a constructor with two parameters
- Write getters and setters for each of the members
- Write a test, creating a Couple <Integer,String>
- Try to call getters and setters respecting the given types
- Try to call getters and setters that do not respect the given types
Extra practice: EmployeeDAOMapImpl
- Write an EmployeeDAOMapImpl for practice 6-2 using a Map as internal storage. Start from a copy of the EmployeeDAOMemoryImpl
- Have the factory return the EmployeeDAOMapImpl
- Test and correct until the program runs well
Lesson JUnit
practice DAO
- Add a reset() method to the EmployeeDAO from practice 6-2 that clears the employee storage
- Create a JUnit 4 testcase for the EmployeeDAO
- Right click on the class and select tools > create Tests
- The testcase is created in a dedicated test directory
- in which package does the testcase reside?
- Complete the generated testcase
- In the @BeforeClass method create the DAO object and store it in a static attribute
- In the @Before method, initialise the employee table with 3 records
- Hint: to make a Date object use Calendar cal = Calendar.getInstance();
// you can reuse the same cal object for multiple dates
// set the date to januari 6th 2013
cal.set(2013, 0, 6);
Date d = cal.getTime();
- Write tests for all operations
- You may add a setter method to Employee for testing the update operation
- Right click the project and select Test (or press ALT+F6)
- Test until all tests succeed
Lesson 8
Extra practice: CSV changer
Write a unit test that replaces all blanks in a file by colons. Multiple blanks should be replaced by only one colon.
No comments:
Post a Comment