Advertisement
tjb1

Untitled

Nov 23rd, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import java.io.File;
  2. import java.util.Scanner;
  3.  
  4. public class Chap5prob14_fileDISPLAY {
  5.  
  6. //data members
  7. // are the basic characteristics of the object
  8. private String filename;
  9.  
  10.  
  11.  
  12. //method members
  13. //are the functionalities of the object
  14.  
  15. //constructors These methods create (instantiate) an instance of the object
  16.  
  17. /**
  18. * Default constructor sets the filename to ""
  19. */
  20. public Chap5prob14_fileDISPLAY(){
  21. filename = "";
  22.  
  23. }
  24.  
  25. /**
  26. * full constructor sets the packageLetter and the hours according to the parameters
  27. * @param filename is the Package Letter Choice
  28. */
  29. public Chap5prob14_fileDISPLAY(String filename){
  30. this.filename = filename;
  31.  
  32. }
  33.  
  34. //getters
  35.  
  36. /**
  37. * this method returns the packageLetter
  38. * @return the packageLetter
  39. */
  40. public String getfilename(){
  41. return filename;
  42. }
  43.  
  44.  
  45.  
  46. //setters
  47.  
  48. /**
  49. * This method resets the packageLetter and hours according to the parameter
  50. * @param value will be set as the new value
  51. */
  52. public void setfilename( String value ) {
  53. this.filename = value;
  54. }
  55.  
  56.  
  57. //toString method
  58.  
  59. public String toString(){
  60. String str;
  61.  
  62. str = ("\tThe file name you entered is: " + filename);
  63. return str;
  64. }
  65.  
  66. //all other object specific methods
  67. Scanner input = new Scanner(filename);
  68. double lineCount = 0;
  69. String file = "";
  70.  
  71. public String displayHead() {
  72. while(input.hasNext()){
  73. lineCount++;
  74. }
  75. while(lineCount <=4 || input.hasNext());
  76. file = ("input.next()");
  77. return file;
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement