Create A Face Mini-Lab
Explore text blocks and escape sequences to create a face using characters and symbols.
Required Knowledge
This series of labs require you to write program code to use the following topics.
- Learn: Console Input and Output
- Learn: Formating Output with Escape Sequences and Text Blocks
- Learn: Formating Output with Text Blocks
Prepare Your IDE
The Java Playground is great for trying out segments of code, but if we write print statements to show that the output doesn't move to the next line, it won't behave as we expect. That is because it will treat each print statement distinctly. At this time, to test out some code, we will want to move over to an IDE. If you need help, please reference the Getting Set-up page.
In this section, we will be using preview features in JDK 24. To use features that are still in preview, you will need to enable preview features in your IDE.
- Create a
.javafile. The file name should start with an uppercase letter. - Use the following
mainmethod template. Add your statements to the body of themainmethod. A comment is in the body of themain. A comment is ignored by the compiler. Comments are added to the program code to help programmers understand what the program code does. There are three types of comments:- single-line comments start with
// - multi-line comments start with
/*and end with*/ - document comments, which generate documentation, start with
/**and end with*/
- single-line comments start with
Mission - Character Art
Use text blocks and escape sequences to create a face with characters. Here is an example of what your face might look like, but feel free to be creative and make your face your own.
Before you write program code to create your face, it is recommended that you draw you face out on graph paper. Place each character in it's own box. The font used when printing the output to the screen will space out each character equally, so using graph paper will help you to know just how many of each characters you will need. For example, if you wanted a part in the middle of the hair on top of the face, you might draw out:
\\\\////
Because of escape sequences, you will need twice the number of backslash characters as forward slash characters, so the line might be:
Mission 1
Use escape sequences to create your face.
Mission 2
Use text blocks to create your face.