Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TextFile
- {
- private String fileName;
- private ArrayList<String> words;
- // constructors not shown
- // postcondition: returns the number of bytes in this file
- public int fileSize()
- {
- }
- // precondition: 0 <= index < words.size()
- // postcondition: removes numWords words from the words ArrayList beginning at
- // index.
- public void deleteWords(int index, int numWords)
- {
- }
- // precondition: 0 <= index <= words.size()
- // postcondition: adds elements from newWords array to words ArrayList beginning
- // at index.
- public void addWords(int index, String[] newWords)
- {
- }
- // other methods not shown
- }
- Complete the fileSize() method. The fileSize() is computed in bytes. In a text file, each character in each word counts as one byte. In addition, there is a space in between each word in the words ArrayList, and each of those spaces also counts as one byte.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement