/* * Created on Jul 5, 2004 */ /** * @author dickey */ public class Filler { public Filler(int fillMax) { this.MAX_FILL = fillMax; } public int MAX_FILL = 20; public String fill(String orig, int flength, char fillChar) { int fcount = flength - orig.length(); if (fcount <= 0) { return orig; } fcount = Math.min(fcount, this.MAX_FILL); char[] fillChars = new char[fcount]; for (int c = 0; c < fcount; c++) { fillChars[c] = fillChar; } String retValue = new String(fillChars) + orig; return retValue; } } /* 1. What does the fill method do? 2. Why or when might it be useful? 3. Should the instance variable have the capitalization it does? 4. What would be some appropriate Java documentation comments? 5. What are some likly invariants for the instance variable? 6. What are some likely preconditions for the constructor and the method? 7. Where are some likely postconditions of the method? 8. How could you test the class and the method? Write a test case or cases which could detect errors in a faulty implementation. */