Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.Scanner;
- public class Chap5prob14_fileDISPLAY {
- //data members
- // are the basic characteristics of the object
- private String filename;
- //method members
- //are the functionalities of the object
- //constructors These methods create (instantiate) an instance of the object
- /**
- * Default constructor sets the filename to ""
- */
- public Chap5prob14_fileDISPLAY(){
- filename = "";
- }
- /**
- * full constructor sets the packageLetter and the hours according to the parameters
- * @param filename is the Package Letter Choice
- */
- public Chap5prob14_fileDISPLAY(String filename){
- this.filename = filename;
- }
- //getters
- /**
- * this method returns the packageLetter
- * @return the packageLetter
- */
- public String getfilename(){
- return filename;
- }
- //setters
- /**
- * This method resets the packageLetter and hours according to the parameter
- * @param value will be set as the new value
- */
- public void setfilename( String value ) {
- this.filename = value;
- }
- //toString method
- public String toString(){
- String str;
- str = ("\tThe file name you entered is: " + filename);
- return str;
- }
- //all other object specific methods
- Scanner input = new Scanner(filename);
- double lineCount = 0;
- String file = "";
- public String displayHead() {
- while(input.hasNext()){
- lineCount++;
- }
- while(lineCount <=4 || input.hasNext());
- file = ("input.next()");
- return file;
- }
- }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement