Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions 1-introduction-to-kotlin/Art_robot.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
Author: AnOnYmOus001100
Date: 05/10/2020
Description:
ASCII Art
Programming and art are often viewed as opposites, but that couldn’t be farther from the truth. Coding can be a great medium for artistic creativity! One example of this is ASCII art.

ASCII stands for American Standard Code for Information Interchange. Its general purpose is to give every character, from letters to numbers to symbols, its own unique character code so that the character can be recognized in a digital space.

It can also be used to create art!

ASCII art is a drawing technique that uses a combination of different keyboard characters to create both simple and complex images:

ASCII Art

The ASCII image above is made up of several characters; for example, the petals on the flower were created using (, _, and ).

In this project, we will be using print statements to create our own ASCII art image in Kotlin!

Tasks

Planning the Art
1.
Decide on an image you would like to recreate via ASCII art.

For example:

Robot
Plant
Cat

2.
Before we try to use print statements, let’s draft our ASCII drawing in the editor.

Create a multiline comment. Inside the comment, use different letters, numbers, and symbols to draft out your image.


Creating the Program
3.
Now that we have some ASCII art, let’s create a program that outputs our image to the terminal!

First, create the main() function. We’ll add code to the main() function body in the next step.


4.
Now, we’ll create our print statements.

For every line in the ASCII art image, use println() to create a print statement that contains all the values that exist in that line of art.


5.
Once all the print statements are created, run the program and see how the drawing looks!

If something doesn’t look right, now is the time to go back into the code to make the proper edits.

Keep editing the program until you feel satisfied with the final result.


Optional
6.
Great job completing the project!

If you want to keep challenging yourself, check out these additional tasks:

Add a background to your ASCII image.
Recreate the ASCII art using only one print statement. To accomplish this, you’ll need to use \n. Check out the hint below to learn more!


7.
Sample Solutions:

Art.kt
If you make something cool, share it with us!
*/

// Write your code below
/*
||
____[]_____
<=| @ @ |=>
| ^ |
| 000 |
|________|
| |
___________| |__________
|(O)____ _____(O)|
| | |==========| | |
|()| | | |()|
|()| |OOOOOOOOOO| |()|
| | | | | |
| | |==========| | |
/----| | | | | /----|
/_( )_| | | | | /_( )_|
| | | |
|()| |()|
|()| |()|
| | | |
___| | | |___
|______| |______|
*/

fun main() {

println(" ||")
println(" ____[]_____")
println(" <=| @ @ |=>")
println(" | ^ |")
println(" | 000 |")
println(" |________|")
println(" | |")
println(" ___________| |__________")
println(" |(O)_____ _____(O)|")
println(" | | |==========| | | ")
println(" |()| | | |()|")
println(" |()| |OOOOOOOOOO| |()|")
println(" | | | | | |")
println(" / | |==========| / |")
println(" |----| | | | | |----|")
println(" /_( )_| | | | | /_( )_|")
println(" | | | |")
println(" |()| |()|")
println(" |()| |()|")
println(" | | | |")
println(" ___| | | |___")
println(" |______| |______|")
}