SlideShare a Scribd company logo
1 of 3
Download to read offline
CSC-141 Introduction to Computer Programming Spring-2013
Assignment 2
CSC-141 Introduction to Computer Programming
Instructor: Saba Anwar
Class: FA12-BPH-A
Total Marks: 50
Assignment Date Saturday May 18, 2013
Submission Date and Time: Monday May 25, 2013 by 11:55 PM
Submission Guidelines:
This is an individual assignment. For collaboration rules, please consult academic rules /honor code
(placed at website).Your submitted work will be compared with that of your friends, and copied work will
lead you to strict penalty.
When you are done with both questions, place your name and roll number in comments at start of each
program. Save each file with filename of this pattern: FA12BPH-0XX-1.c and FA12-0XX-2.c. XX is your
ID and 1, 2 represent Task number.
Send both files in a single mail with subject FA12-BPH-A [Assignment1] to
ciitsubmissions@gmail.com
Any violation may misplace your assignment and you will be marked as “Absent” in assignment.
You may submit it late as well. 20% marks will be deducted for late submission of one day and 40%
marks will be deducted for late submission of two days. No assignment will be accepted after 48 hours.
__________________________________________________________________________________
Task 1
A possible 2D array is given below
You can see that its last cell is empty. Implement the following program:
Numbers should be displayed in the above fashion. Allow the user to hit any of the arrow
keys (up, down, left or right). If user hits up key, then the piece with number 4 and blank
piece will be swapped, and this table will look like:
CSC-141 Introduction to Computer Programming Spring-2013
After that if user hits left key, then the piece with number 43 and blank piece will be swapped
and table will look like:
If user hits left key and there is no column on left, then it should give appropriate message. With every
hit, it will check whether numbers are sorted in ascending order or not. When all 15 integers are sorted
and blank is at last position, then it should stop by giving success message, and this table will look like:
To keep track of keys, use getch() and identify each key by its ASCII codes as follows:
 Up arrow key: 72
 Down arrow key: 80
 Right arrow key: 75
 Left arrow key: 77
It should also show number of moves at each step. It may also be stopped by press ‘q’ somewhere to
quit the program.
Task 2
CSC-141 Introduction to Computer Programming Spring-2013
In this task you will be implementing a simple board game called Dungeon Crawl. It will use a simple 2D
string array to draw the game board. The board should be like following:
… P ………
…… E ……
…… E ……
……… E …
… E ………
……… E …
………… $
P is the player, E’s are enemies, and $ is the treasure. Objective of the game is to safely steal the hidden
treasure in the dungeon. Following are the rules of game
1. P can move in any direction but it should not go beyond the board boundary, if it goes he dies
and game will be lost.
2. If P collides with any enemy, its life points are decreased by 1. The total points are 3 at start.
Display life points along with board throughout the game.
3. Enemies can be placed anywhere on board randomly, every time game starts, But player’s
position can be fixed in 1st
row where ever you want. You can set number of enemies yourself,
but minimum they should be 5
Use arrows keys to move the player on board
Bonus point: you can move enemies in random directions with every move of player.
___________________________________________

More Related Content

Similar to Assignment 2

COMP 220 HELP Lessons in Excellence--comp220help.com
COMP 220 HELP Lessons in Excellence--comp220help.comCOMP 220 HELP Lessons in Excellence--comp220help.com
COMP 220 HELP Lessons in Excellence--comp220help.comthomashard85
 
Assignment Pong
Assignment PongAssignment Pong
Assignment PongSusan Gold
 
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4  A game and an email system.docxJava Helpa4.pdfASSIGNMENT 4  A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docxpriestmanmable
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docxoswald1horne84988
 
COMP 220 Entire Course NEW
COMP 220 Entire Course NEWCOMP 220 Entire Course NEW
COMP 220 Entire Course NEWshyamuopeight
 
ontents · Introduction· Objectives·.docx
ontents  ·      Introduction·      Objectives·.docxontents  ·      Introduction·      Objectives·.docx
ontents · Introduction· Objectives·.docxcherishwinsland
 
Omp 220 complete class omp220
Omp 220 complete class omp220Omp 220 complete class omp220
Omp 220 complete class omp220arnitaetsitty
 
I have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdfI have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdfaayushmaany2k14
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxabhi353063
 
I have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdfI have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdfFORTUNE2505
 
Agent tic tac-toe - an interactive game for computational thinking
Agent tic tac-toe - an interactive game for computational thinkingAgent tic tac-toe - an interactive game for computational thinking
Agent tic tac-toe - an interactive game for computational thinkingLorennRuster
 
Hurdle Race Game
Hurdle Race GameHurdle Race Game
Hurdle Race GameAsawal
 
2 Level Guitar Hero Final Report
2 Level Guitar Hero Final Report2 Level Guitar Hero Final Report
2 Level Guitar Hero Final ReportCem Recai Çırak
 

Similar to Assignment 2 (15)

COMP 220 HELP Lessons in Excellence--comp220help.com
COMP 220 HELP Lessons in Excellence--comp220help.comCOMP 220 HELP Lessons in Excellence--comp220help.com
COMP 220 HELP Lessons in Excellence--comp220help.com
 
Assignment Pong
Assignment PongAssignment Pong
Assignment Pong
 
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4  A game and an email system.docxJava Helpa4.pdfASSIGNMENT 4  A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docx
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docx
 
COMP 220 Entire Course NEW
COMP 220 Entire Course NEWCOMP 220 Entire Course NEW
COMP 220 Entire Course NEW
 
ontents · Introduction· Objectives·.docx
ontents  ·      Introduction·      Objectives·.docxontents  ·      Introduction·      Objectives·.docx
ontents · Introduction· Objectives·.docx
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Bow&arrow game
Bow&arrow gameBow&arrow game
Bow&arrow game
 
Omp 220 complete class omp220
Omp 220 complete class omp220Omp 220 complete class omp220
Omp 220 complete class omp220
 
I have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdfI have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdf
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docx
 
I have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdfI have another assignment due for an advance java programming class .pdf
I have another assignment due for an advance java programming class .pdf
 
Agent tic tac-toe - an interactive game for computational thinking
Agent tic tac-toe - an interactive game for computational thinkingAgent tic tac-toe - an interactive game for computational thinking
Agent tic tac-toe - an interactive game for computational thinking
 
Hurdle Race Game
Hurdle Race GameHurdle Race Game
Hurdle Race Game
 
2 Level Guitar Hero Final Report
2 Level Guitar Hero Final Report2 Level Guitar Hero Final Report
2 Level Guitar Hero Final Report
 

Assignment 2

  • 1. CSC-141 Introduction to Computer Programming Spring-2013 Assignment 2 CSC-141 Introduction to Computer Programming Instructor: Saba Anwar Class: FA12-BPH-A Total Marks: 50 Assignment Date Saturday May 18, 2013 Submission Date and Time: Monday May 25, 2013 by 11:55 PM Submission Guidelines: This is an individual assignment. For collaboration rules, please consult academic rules /honor code (placed at website).Your submitted work will be compared with that of your friends, and copied work will lead you to strict penalty. When you are done with both questions, place your name and roll number in comments at start of each program. Save each file with filename of this pattern: FA12BPH-0XX-1.c and FA12-0XX-2.c. XX is your ID and 1, 2 represent Task number. Send both files in a single mail with subject FA12-BPH-A [Assignment1] to ciitsubmissions@gmail.com Any violation may misplace your assignment and you will be marked as “Absent” in assignment. You may submit it late as well. 20% marks will be deducted for late submission of one day and 40% marks will be deducted for late submission of two days. No assignment will be accepted after 48 hours. __________________________________________________________________________________ Task 1 A possible 2D array is given below You can see that its last cell is empty. Implement the following program: Numbers should be displayed in the above fashion. Allow the user to hit any of the arrow keys (up, down, left or right). If user hits up key, then the piece with number 4 and blank piece will be swapped, and this table will look like:
  • 2. CSC-141 Introduction to Computer Programming Spring-2013 After that if user hits left key, then the piece with number 43 and blank piece will be swapped and table will look like: If user hits left key and there is no column on left, then it should give appropriate message. With every hit, it will check whether numbers are sorted in ascending order or not. When all 15 integers are sorted and blank is at last position, then it should stop by giving success message, and this table will look like: To keep track of keys, use getch() and identify each key by its ASCII codes as follows:  Up arrow key: 72  Down arrow key: 80  Right arrow key: 75  Left arrow key: 77 It should also show number of moves at each step. It may also be stopped by press ‘q’ somewhere to quit the program. Task 2
  • 3. CSC-141 Introduction to Computer Programming Spring-2013 In this task you will be implementing a simple board game called Dungeon Crawl. It will use a simple 2D string array to draw the game board. The board should be like following: … P ……… …… E …… …… E …… ……… E … … E ……… ……… E … ………… $ P is the player, E’s are enemies, and $ is the treasure. Objective of the game is to safely steal the hidden treasure in the dungeon. Following are the rules of game 1. P can move in any direction but it should not go beyond the board boundary, if it goes he dies and game will be lost. 2. If P collides with any enemy, its life points are decreased by 1. The total points are 3 at start. Display life points along with board throughout the game. 3. Enemies can be placed anywhere on board randomly, every time game starts, But player’s position can be fixed in 1st row where ever you want. You can set number of enemies yourself, but minimum they should be 5 Use arrows keys to move the player on board Bonus point: you can move enemies in random directions with every move of player. ___________________________________________