Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public class TextFile
  2. {
  3.  
  4. private String fileName;
  5.  
  6. private ArrayList<String> words;
  7.  
  8. // constructors not shown
  9.  
  10. // postcondition: returns the number of bytes in this file
  11.  
  12. public int fileSize()
  13.  
  14. {
  15.  
  16. }
  17.  
  18. // precondition: 0 <= index < words.size()
  19.  
  20. // postcondition: removes numWords words from the words ArrayList beginning at
  21.  
  22. // index.
  23.  
  24. public void deleteWords(int index, int numWords)
  25.  
  26. {
  27.  
  28. }
  29.  
  30. // precondition: 0 <= index <= words.size()
  31.  
  32. // postcondition: adds elements from newWords array to words ArrayList beginning
  33.  
  34. // at index.
  35.  
  36. public void addWords(int index, String[] newWords)
  37.  
  38. {
  39.  
  40. }
  41.  
  42. // other methods not shown
  43.  
  44. }
  45. 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