You are on page 1of 12

# Tetris and Number ASCII ART

CSD Assignment #1

By
105998409

International Electrical Engineering and Computer Science
Taipei Tech
Date Submitted: October 6, 2016

Figure 2. For example: Figure 1. Specification In this Assignment students are asked to display some ASCII art which represent 19 kinds of Tetris block and also 10 kinds of digits. For Digits: 7x7 matrix can be used to show the number. 4x4 matrix can be used to show the Tetris. For Tetris: Students are instructed to make 19 kinds of Tetris ASCII Art. Figure 3. A sample of main menu display. Shape reference for Tetris ASCII Art. . The program has to display a menu to use the system. As well displaying a sub menu for each option in the main menu. Sub menu display examples.

". O\n" O\n" O\n" O\n\n". cout << "O O O ". cout << "Please insert the number: ". cout << "."..". switch (tetris) { case 1: cout << "\n". break. case 5: cout << "\n". cout << "O O O ".. case 4: cout << "\n"..."...break. cin >> tetris."O .". -\n" -\n" -\n" O\n\n"."O .- O\n" O\n" -\n" -\n\n".break. cout << "O O "O .. cout << "\n". . case 2: cout << "\n".". -\n" -\n" -\n" -\n\n". case 3: cout << "\n".O break.//************************************************************************* **** // Switch menu to display the menu. cout << "... //************************************************************************* **** switch (choice) { case 1: int tetris.O "."O ... cout << "You have chosen Tetris \n" "Chose 1~19\n" "Chose -1 for back\n"."O O O break. -\n" -\n" -\n" -\n\n".".

.break. cout << ".". O\n" O\n" O\n" O\n\n".. cout << ". cout << "O O O "O ."... cout << "."."O ... cout << ".break. case 12: cout << "\n". case 7: cout << "\n".case 6: cout << "\n".. cout << ".". -\n" -\n" -\n" -\n\n".O "O O O break.. -\n" -\n" -\n" -\n\n". case 9: cout << "\n"..."O .break.. -\n" -\n" O\n" O\n\n"."O O "O .break.". cout << "O O "O .". -\n" -\n" -\n" -\n\n".. . O\n" -\n" -\n" -\n\n".O ". case 10: cout << "\n".. case 8: cout << "\n".". -\n" -\n" -\n" -\n\n".break."O .O "."O O O break.O "O O ".". case 11: cout << "\n".

"O O O break."..O break. cout << ".break. case 14: cout << "\n".". . -\n" -\n" -\n" -\n\n"..case 13: cout << "\n". cout << ". -\n" -\n" -\n" -\n\n".".O O "O O break. -\n" -\n" -\n" -\n\n".O O break. case -1: cout << "\nGood Bye!\n\n".O "O O "O .break.. break. case 19: cout << "\n"."O . cout << "O . -\n" -\n" -\n" O\n\n". -\n" -\n" -\n" -\n\n"."O .. -\n" -\n" -\n" -\n\n"."."O O "."... -\n" -\n" -\n" -\n\n". case 18: cout << "\n".". cout << ". cout << ". case 16: cout << "\n"....."."O . cout << "."O ."O O "O O break. case 17: cout << "\n". cout << ". case 15: cout << "\n".."O O ".

cout << "--OOOO-\n" "-OO--OO\n" "-----OO\n" "----OO-\n" "---OO--\n" "-OO----\n" "OOOOOOO\n\n". cout << "----OOO\n" "--OO-OO\n" "-OO--OO\n" "OOOOOOO\n" "-----OO\n" "-----OO\n" "-----OO\n\n". cin >> ascinumber. getchar(). switch (ascinumber) { case 1: cout << "\n".while(choice!=-1). case 2: int ascinumber. getchar(). cout << "\n". break. cout << "-OOOOOO\n" "OO---OO\n" "----OOO\n" "--OOO--\n" "----OOO\n" "OO---OO\n" "-OOOOOO\n\n". case 4: cout << "\n". cout << "Please insert the number: ". cout << "You have chosen Number \n" "Chose 0~9\n" "Chose -1 for back\n". . break. break. cout << "---OO--\n" "--OOO--\n" "-OOOO--\n" "--OOO--\n" "--OOO--\n" "--OOO--\n" "-OOOOO-\n\n". } break. case 3: cout << "\n". case 2: cout << "\n".

case 6: cout << "\n". break. break. cout << "OOOOOOO\n" "OOO----\n" "OO-----\n" "OOOOOOO\n" "-----OO\n" "----OOO\n" "OOOOOO-\n\n". break. cout << "-OOOOO-\n" "OO---OO\n" "OO---OO\n" "-OOOOO-\n" "OO---OO\n" "OO---OO\n" "-OOOOO-\n\n". break. . case 9: cout << "\n". case 8: cout << "\n". case 5: cout << "\n". cout << "OOOOOOO\n" "OO---OO\n" "----OOO\n" "---OOO-\n" "--OOO--\n" "-OOO---\n" "OOO----\n\n". break. cout << "-OOOOO\n" "OO-----\n" "OO-----\n" "OOOOOOO\n" "OO---OO\n" "OO---OO\n" "-OOOOO-\n\n".break. case 7: cout << "\n". cout << "-OOOOO-\n" "OO---OO\n" "OO---OO\n" "-OOOOOO\n" "-----OO\n" "-----OO\n" "-OOOOO-\n\n".

.- cout << " 5.- " ..- cout << " 9.. ..- O ... ..O O 11..- cout << "13. O O O - 6...- 7... O .- O O ..- \n" \n" \n\n"..O .- O ..O .O O - O O .O ..- O O O - O .- 16......- ..- ...O O O O O O O . . O O O O 10. \n" " . "There is a list for Tetris Menu:\n\n".case 0: cout << "\n".....- .. ..- .- .- " .- O .- O ...- . ..O 3..- ......- 8..O O O O O O O .... case -1: cout << "\nGood Bye!\n\n".- \n" \n" \n\n". break. getchar().O .- ....O .O .O . ... " 1..- " . O . .. break. O O .- O .O . O O O O 2. "You have chosen help\n".- 12.. \n" " O .- 14...- . while(choice!=-1). \n" " .- " ...- O .- . getchar().- 15.- 4. .- .O O . ... } break...- O O ..- " .O O ...O ....- " .. cout << "-OOOOO-\n" "OO---OO\n" "OO---OO\n" "OO---OO\n" "OO---OO\n" "OO---OO\n" "-OOOOO-\n\n"..- O ..- .- O ..- \n" \n" \n\n". ..- O O O \n" \n" O\n\n".- \n" " ...- " O O . case 3: cout cout cout cout << << << << "\n".- " .. .

.- \n" \n" \n\n"..... . Goodbye. ... .- 18.- O O .- " O O .- \n" " . } }while(choice!=4). break.- 19..\n\n". cout << "You have chosen Quit.O O - O . case 4: cout << "\n".- " O O . cout << "The program is created by Muhammad Yusuf Fadhlan\n" " 105998409 \n" " 2016 \n\n".O .- . getchar().. break.- . The main menu display ..- O O . default: cout<< "Your selection must be between 1 and 4!\n\n".. getchar().cout << "17.- . }  Testing Figure 4.

The Number Sub Menu display if number 2 is submitted. . Figure 6. One of 19 shapes of Tetris. The Tetris Sub Menu display when user choose 1. Figure 7.Figure 5.

 Time Table Homework 1 Date 20161001 Start 10:00 Stop 13:00 20161004 20:00 22:00 20161006 20161006 Total hours: 10 13:00 19:00 17:00 20:00 Comment Make a structure of the program such as main menu and its sub menu.Figure 8. The output that is shown if user input 9. o The Switch function is very essential for this homework.  Conclusion o This homework uses a lot of ASCII art for the output. Make a ASCII layout for Tetris and Number Display Finishing the code Make a report .