Introduction
ASCII Art is an age-old tradition with computers and has existed since before computers were truly a thing. In fact, it dates back to art done in 1875 as part of newspaper prints - just using the text of the advertisement to draw a picture. The term ASCII comes from American Standard Code for Information Interchange, which is basically how numbers get translated to characters on a computer. How many of you have done a fun emoji or sign off signature? You have essentially typed out some ASCII art. In this assignment, you will create your own ASCII art with a purpose and are encouraged to have fun.
Important: The ASCII art you generate in this assignment, you will post to the discussion board as one of your writing assignments. As such, it is important to take your time and be creative.
In this lab you will learn:
- More System.out.print/println
- Using methods to divide a problem into smaller parts.
- Using method returns to set variable values
- String concatenation
/\___/\
(=~_~=)
.*•.¸¸.•*
.¸.•**•.¸.•*¨) ¸.•*¨)
.(")__(") (¸.•* (¸.•*¨*•?
**** GOOD LUCK CAT ***
What is a name? (Step 1)
Let’s warm up. All the methods you write in this assignment will be returning a String object. As such, let’s write a simple method to start.
-
Find the public static method called getAstrologerName(). It currently has a default return value, modify it to simply return your name as a String.
-
After you have done that, go to the public static void main(String[] args) method (called the main method). You should print out your Astrologer Name using the method you just finished. For example:
public static void main(String[] args) {
System.out.println("======Part One======");
System.out.println(getAstrologerName());
}
Run your program now. It does not take in any program arguments and make sure to not waste submissions. Instead, just run it. If you did it correctly, your name will appear in the output.
How to contact you? (Step 2)
You should now find the public static method called getAstrologerEmail(). As with the name method, you should change the default return value to return your student email address as a String.
After you create the method, you should test it by going back to your main and printing out the astrologer email in the ‘Part 1’. For example:
public static void main(String[] args) {
System.out.println("======Part One======");
System.out.println(getAstrologerName());
System.out.println(getAstrologerEmail());
System.out.println("\n\n======Part Two======");
}
Business Card (Step 3)
Now that you have warmed up, you will use these methods to build a much more complex String. This method will involve using the parameters you pass into the method, along with using the newline special character “\n”. It is also easier if you concatenate it based on each ‘line’ of the card.
- Find the public static method called getBusinessCard(String name, String email) It will return a String similar to the following two examples:
+--------------------------------------+
| CSU Astrology |
| Rams for the Stars |
| |
| |
| Albert Lionelle |
| lionelle@colostate.edu |
+--------------------------------------+
+--------------------------------------+
| CSU Astrology |
| Rams for the Stars |
| |
| |
| Amy Pond |
| apond@rams.colostate.edu |
+--------------------------------------+
Here are the things you need to know, before tacking the problem of building your business card String.
- The card is exactly 40 characters wide. Meaning the first line is has 38 dashes and two plus signs.
- CSU Astrology should be in the top left corner.
- Rams for the Stars should be in the top left corner, under CSU Astrology.
- Your name in the bottom right - use the name parameter from the method signature.
- Your email in the bottom right, with one space before the vertical bar - use the email parameter from the method signature.
- If your name is longer than your email, feel free to shorten your name.
Before you start writing your full business card, it would be wise to simply return the first line, before writing the next one. As such, once you get the first line in the method, you should edit your main method with the following changes.
public static void main(String[] args) {
System.out.println("======Part One======");
System.out.println(getAstrologerName());
System.out.println(getAstrologerEmail());
System.out.println("\n\n======Part Two======");
String astroName = getAstrologerName();
String astroEmail = getAstrologerEmail();
System.out.println(getBusinessCard(astroName, astroEmail)); // is there a way to do this in one line?
}
Now continue to run the program, as you write it. This will help you to easily determine your spacing and notice any mistakes.
Astrology Cards (Step 4)
Now we have worked up to the creative part! You will write three methods. All of them public static and they will all return separate Strings. The three methods you will write are called:
- getAries()
- getLeo()
- getSagittarius()
Yes, the three ‘fire’ signs. For each of the ‘cards’. The following rules apply.
- It must include the sign name in caps with five dashes, for example: ===== ARIES =====
- It must look like a card
- You should be creative about it. I personally had fun pulling the constellation / astronomy side.
Here are some sample cards
+----------------------------------------+
| * |
| |
| * |
| * |
| * |
| * |
| ===== CANCER ===== |
+----------------------------------------+
+----------------------------------------+
| |
| |
| .''-._.-''-._.- |
| .''-._.-''-._.- |
| |
| |
| ===== AQUARIUS ===== |
+----------------------------------------+
+----------------------------------------+
| /`·.¸ |
| /¸...¸`:· |
| ¸.·´ ¸ `·.¸.·´ |
| : © ):´; ¸ { |
| `·.¸ `· ¸.·´\`·¸) |
| `\´´\¸.·´ |
| ===== PISCES ===== |
+----------------------------------------+
You will notice they are very different.
I recommend adding the following to your main - but only add one line at a time, as you work on each method.
public static void main(String[] args) {
System.out.println("======Part One======");
System.out.println("Name: "+ getAstrologerName());
System.out.println("Email: " + getAstrologerEmail());
System.out.println("\n\n======Part Two======");
System.out.println(getBusinessCard(getAstrologerName(), getAstrologerEmail()));
System.out.println("\n\n======Part Three======");
System.out.println(getAries());
System.out.println(getLeo());
System.out.println(getSagittarius());
}
This is actually my completed main for the program.
Turning In (Step 5)
As with the previous labs, you have 5 attempts to submit your assignment for grading. For grading, you will find I am ignoring your main method, but instead I will be testing the individual methods. This is very common in programming as someone else can take the code you write, and ‘glue’ the problems you solved together in different ways building something new - similar to LEGOs!