Java Bootcamp – Workbooks and Challenges
)}

Workbook 4.1

From the Java Bootcamp Resources, launch the Workbook 4.1 folder.

4.1.png

Bart's detention.


Bart's teacher wants him to write lines on the chalkboard.

He needs to write this paragraph 6 times:

I will not copy and paste code.

I will use Camel Case when writing class names.

I will use lower Camel Case when writing function names.

I will use lower Camel Case when writing variables names.

Bart wrote the paragraph once, but it took him a long time!

public class Detention {

     public static void main(String[] args) {
         //what Bart did so far
         System.out.println("I will not copy and paste code.");
         System.out.println("I will use Camel Case when writing class names.");
         System.out.println("I will use lower Camel Case when writing function names.");
         System.out.println("I will use lower Camel Case when writing variables names.");
    }

}

>> I will not copy and paste code.

>> I will use Camel Case when writing class names.

>> I will use lower Camel Case when writing function names.

>> I will use lower Camel Case when writing variables names.

Task 1 - Write a function


Help Bart write a function that does the task for him. The doc comment will guide you.

    /**
      * Function name: printLines
      *
      * Inside the function:
      *   1. prints the four lines
      */

A doc comment is embedded inside /** ... */. They're best at describing the function name, parameters, and return value.

  • The name of the function is printLines.
    /**
      * Function name: printLines  <--
      *
      * Inside the function:
      *   1. prints the four lines
      */
  • The comment says nothing about parameters, so you can assume it doesn't take any.

  • The comment says nothing about a return value. So, you can assume the function is void.

  • Inside the function, it prints the four lines.

    /**
      * Function name: printLines
      *
      * Inside the function:
      *   1. prints the four lines    <--
      */

The doc comment outlines everything you need to make your function.

Task 2 - Call the function


Once you finish writing it, call the function six times from main().

Run your code.


   >>I will not copy and paste code.
   >>I will use Camel Case when writing class names.
   >>I will use lower Camel Case when writing function names.
   >>I will use lower Camel Case when writing variables names.

   >>I will not copy and paste code.
   >>I will use Camel Case when writing class names. 
   >>I will use lower Camel Case when writing function names.
   >>I will use lower Camel Case when writing variables names.
   
   >>I will not copy and paste code.
   >>I will use Camel Case when writing class names.
   >>I will use lower Camel Case when writing function names.
   >>I will use lower Camel Case when writing variables names.

   ...

Visualizing the Runtime

After you solve this workbook, I still recommend watching the video solution on Udemy.

4.1.png

It will show you how to visualize the runtime using Visual Studio Code.


Associated Course: The Complete Java Development Bootcamp
Related Course: The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary
4.7
43 students
5

91%
4

2%
3

0%
2

0%
1

7%
Written Reviews
There are no written reviews yet.