PT-P32 Test

(Project Test Home Page)

# Question
1

Create a Java Application which shows the implementation of your knowledge of the following concepts.  You can use the Java API while creating your program and the JDK's compiler to compile.  No other resources can be used.

Metrics:

  • #1, 10 pts:   Place good comments in your program.  Also comment, using the inline comment //, each of the metrics that you implemented (10pts).  Make sure your comment has the Metric #!!!
  • #2, 10 pts: Create the Java class that does not extend any classes and does not create a GUI frame.  You will be using the Java Console for all output.   Make your class accessible to the public.  Also  Create a _comile.bat and an _run.bat file to compile and test your program.
    The filename should follow this naming convention (without extention):
    P32<Lastname>_<Firstname>_<Middlename>.<choose extention>
    • Ex:  If my name was Michael Arthur Thomas, then my .java file name will be:
      P32_Thomas_Michael_Arthur.java
    • Ex:  The _compile.bat & _run.bat would be:
      P32_Thomas_Michael_Arthur_compile.bat
      P32_Thomas_Michael_Arthur_run.bat
  • #3, 10 pts: Create a main() method that will do the following:
    • Instantiate your class (create an object).
    • Run the method with the following signature:
      public void executeProgram()
  • #4, 10 pts: In the method executeProgram(), create a String variable called strContent, which is local to executeProgram(),  with the following content (Note: 1) 4 lines in one String variable, 2) Use \r\n to create a carriage return & new line).

    This is my example of using PrintWriter and BufferedReader class to create a text file.
    This is a simple test if every thing clicks.
    I can't wait to get started.
    Success is the name of the story.
  • #5, 10 pts: Create a method that will display the contents of a String to the Java console.  Use the following method signature:
    private void displayToJavaConsole( String strMsg )
  • #6, 10 pts: Display the String created in executeProgram() to the Java Console using the method you just created.
  • #7, 15 pts: Create a method that will write the contents of strContent to a file.  Call the method from  executeProgram() and pass the filename and strContent to the method.  Use PrintWriter to create the file.  Make the filename follow the following naming convention: P32<Lastname>_<Firstname>_<Middlename>_File.txt.  (Ex:  If my name was Michael Arthur Thomas, then my file name will be: P32_Thomas_Michael_Arthur_File.txt
  • #8, 15 pts: Create a method that will read the contents of the file you created and place the value in a variable named strFileContent which is local to the method executeProgram().  Pass the filename  of the file into the method.  Use BufferedReader to read the file.
  • #9, 10 pts: Pass the variable strFileContent to the method displayToJavaConsole() so that you can test your program.
 
  Place the following at the top of your program if you are a student in an ILT class.

/*
* Student Name..: <Your Name>
* Course........: <Course Code>
* Project.......: P32
* Date handed in: ____________
* Grade:
*   #1 ___ (max 10 pts) Comments 
*   #2 ___ (max 10 pts) File naming & Doesn't extend any classes.
*   #3 ___ (max 10 pts) main()- Create object & run:
public void executeProgram() 
*   #4 ___ (max 10 pts)
strContent w/4 lines, \n
*   #5 ___ (max 10 pts)
private void displayToJavaConsole( String strMsg )
*   #6 ___ (max 10 pts) Display info to JavaConsole 
*   #7 ___ (max 15 pts) Create:
P32<Lastname>_<Firstname>_<Middlename>_File.txt
*   #8 ___ (max 15 pts)
Use BufferedReader to read the file into: strFileContent
*   #9 ___ (max 10 pts)
Pass the variable strFileContent to the method displayToJavaConsole()
*
*      ______ (Project Grade)
*/