CMPT 126 - Harbour Centre - Fall 2006
Home  
Assigned Readings  
Examples  
Labs  
Assignments  
References  
Gradebook  
 
  On this lab (and all future work in this course), the name of the files you submit and the name of the classes they contain must match. That is, the file Foo.java must contain (only) the class Foo.

  1. Create a class Triangle that contains the following functions:
    1. The function triangleLoop should take a string as its argument and print the characters of the string as a “triangle”, adding one character with each line. So, the statement Triangle.triangleLoop("CMPT"); should print this:
      C
      CM
      CMP
      CMPT

      This much be done with a loop.

    2. The function triangleRecursive should do the same as triangleLoop, but must be written recursively. It should not contain a loop.
    3. The function triangleUpLoop should be similar to triangleLoop, but should print a triangle that grows up, instead of down. So, Triangle.triangleUpLoop("CMPT"); should print this:
      CMPT
      CMP
      CM
      C

      This much be done with a loop.

    4. The function triangleUpRecursive should do the same as triangleUpLoop, but must be written recursively. It should not contain a loop.
  2. Create a text file named time.txt. In it, indicate how long it took you to complete this lab exercise.

When you're done, create a ZIP file containing all of the files you created for this lab and submit it with the submission server.