CS 152 Computer Programming Fundamentals Lab 1: ASCII Art

CS 152 Computer Programming Fundamentals Lab 1: ASCII Art

Summer 2017

,ad8888ba, d8"' `"8b d8' 88 88 Y8, Y8a. .a8P

`"Y8888Y"'

ad88888ba d8" "8b Y8, `Y8aaaaa,

`"""""8b, `8b

Y8a a8P "Y88888P"

88 ,d88 888888

88 88 88 88 88

8888888888 88 88 ____ 88a8PPPP8b, PP" `8b

d8 Y8a a8P

"Y88888P"

ad888888b, d8" "88

a8P ,d8P" a8P" a8P' d8" 88888888888

1 ASCII Art

ASCII art is a graphic design technique that consists of pictures pieced together from the 95 printable (from a total of 128) characters defined by the ASCII Standard from 1963 and ASCII compliant character sets. ASCII art can be created with any text editor. Most examples of ASCII art require a fixed-width font (non-proportional fonts, as on a traditional typewriter) such as Courier for presentation.

Examples:

__

(o)--(o)

/.______.\

\________/

./

\.

(.

,)

\ \_\\//_/ /

~~ ~~ ~~

.---.

.-----------

/ \ __ / ------

/ / \( )/ -----

////// ' \/ ` ---

/\_/\

//// / // : : ---

____/ o o \

// / / /` '--

/~____ == /

//

//..\\

(______)__m_m)

=============UU====UU====

'//||\\`

''``

2 Problem Specification

1. Using the Eclipse IDE, create a Java project that contains one class: AsciiArt.java 1

2. Your AsciiArt.java must use Java's System.out.println() function to display to the Java console an ASCII art image that fits within 60x24 columns and rows. It is ok to be smaller than that size. Your image must be a stylized version of your first or last name. Each "letter" must be at least 3x3 characters: printf("William\n") would NOT get credit as an ASCII art image of my name.1

3. Your Java program must have the following format

/** * @version date (in_ISO_8601 format: YYYY -MM -DD) * @author YourFirstName YourLastName */

public class AsciiArt {

/** * Prints my name in ASCII Art to the console. * @param args Command -line arguments are ignored. */

public static void main(String[] args) { // Your code goes here. // Use as many lines as you need. // No line may be more than 80 characters

} }

Note: In Java, comments that begin with /** can be compiled using Javadoc, a documentation generator. The comment format used by Javadoc is the de facto industry standard for documenting Java classes. The @version, @author, and @param annotations are Javadoc tags understood by the Javadoc generator. In this lab, you do not need to generate web pages with Javadoc, but you do need to follow the Javadoc format shown above.

3 Escaping Special Characters

The backslash character has a special meaning in Java strings: it is called an "escape character" and is used to modify the next character in order to generate special characters.

For example, '\n' is the newline character. System.out.println("one fish\ntwo fish") will display:

one fish two fish

A backslash can be used to include a quotation mark in a string. For example, System.out.println("She said \"hello\"") will display:

1There are websites and tools out there that will generate ASCII art from text. Feel free to make use of one of these if you aren't feeling particularly artistic. You will still need to write the Java code to print it.

2

She said "hello"

If you want to actually print a backslash, you need to use a double backslash. System.out.println("\\oo/") will display:

\oo/

4 Turning in your assignment

Submit your AsciiArt.java file into Lab 1 assignment in UNM Learn. Do not attach .class files or any other files.

5 Grading Rubric (total of 20 points)

[1 point]: [2 points]:

[5 points]:

Attached one file in Learn with file name AsciiArt.java. The source code contains neither errors nor warnings when viewed in Eclipse. The code adheres to the specified format. This includes:

1. The author's name and date commented in the format shown.

2. A description of the main method in the format shown.

3. All code in each block is indented exactly four spaces per block structure level. Spaces must be used for indenting, not tabs.

4. No non-space characters may occur on a line after an open curly bracket ({).

5. No characters except spaces are on the same line as any closing curly brackets (}).

6. No line contains more than 80 characters.

[6 points]:

[3 points]: [3 points]:

When compiled and run, the program outputs a beautifully stylized, and readable, ASCII art version of your name in the Java console. (I'm not actually judging your artistic ability here.) Each character of your name is composed of at least 9 characters (3x3). The full name is no larger than 60x24 characters.

____

(_) | (_)

__

___| | |_ __ _ _ __ ___

\ \ /\ / / | | | |/ _` | '_ ` _ \

\ V V /| | | | | (_| | | | | | |

\_/\_/ |_|_|_|_|\__,_|_| |_| |_|

3

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download