You are on page 1of 17

Year 1 (Level 4) CSY1020 – Problem Solving & Programming

CSY1020: Problem Solving & Programming


Assignment 2: Programming (Java) (50%)

Pankaj Kumar Mandal

19436768

BSc Computing

University of Northampton
Submission: Sunday, 4th Aug 2019, by 23h59.
Year 1 (Level 4) CSY1020 – Problem Solving & Programming

TABLE OF CONTENTS

University of Northampton. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1. INTRODUCTION & PROBLEM SPECIFICATION . . . . . . . . .. . . . . . .. . . . . . . . . . 3
1.1. Aim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Error! Bookmark not defined.
1.2. Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . 5
2. ANALYSIS. . . . . . . . . . . . .. . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1. System Requirements: Essential (Graphical User Interface) . . . . . . . . . . . . 6
2.2. System Requirements: Additional (Functionality & Complexity). . . . . . . . . . 6
3. DESIGN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
3.1. GUI Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 7
3.2. Design (Pseudo-code/Flowcharts). . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . 8
4. IMPLEMENTATION . . . . . . . .. . . . . . . .. . . . . . . .. . . . . .. . . .. . . .. . . . . . . . . 9
5. TESTING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
System Requirements: Essential (Graphical User Interface): . . . . . . .. . . . . . . . . .
.......................................................................... Error! Bookmark not defined.
System Requirements: Additional (Functionality & Complexity):. . . . . . . . . . . . . .
.......................................................................... Error! Bookmark not defined.
6. CONCLUSION & RECOMMENDATIONS . . . . . . . . . . . . . . . .. . . . . . . . . . . . . .
Error! Bookmark not defined.
6.1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Error! Bookmark not defined.
6.2. System Requirements: Essential (Graphical User Interface). . . . . . . .. . . .
Error! Bookmark not defined.
6.3. System Requirements: Additional (Functionality & Complexity). . . . . . . . .
Error! Bookmark not defined.
REFERENCES. . . . . . . . . . . . . . . . . . . . . .. . . . . . . .. . . . . . . . . . . . . . . . . . . . . 17
BIBLIOGRAPHY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . .. . . . .
.......................................................................... Error! Bookmark not defined.

TABLE OF FIGURE

Figure 1.1: Emulation - CCarCrash.java Application – Opening State MacOSX. .... 4


Figure 3.1: Emulation - CCarCrash.java Application – Opening State MacOSX.
..................................................................... Error! Bookmark not defined.
Figure 6.1: Emulation - CCarCrash.java Application – Opening State MacOSX.
..................................................................... Error! Bookmark not defined.

LIST OF TABLES

19436768 Pankaj Kumar Mandal 2 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming
1. INTRODUCTION & PROBLEM SPECIFICATION

This is Problem Solving and Programming assignment2. This assignment is associated to set up
the game. This is composed by using java. Scheme is granted in the Nile. Different function should
be added in the given scenario. Using the Green Scenario included, produce a technical report
and accompanying Java GUI application, simulating control of car to navigate around a course
using left, right, up and down buttons/keys. There is fame created which size is 810 x 680. In the
fame there is three panel added, where in the first panel there is wall image is added, black space
image is added and car is added. In the second panel there is fourteen buttons and six text field
added. In the text field there is option text field, square text field, direction text field and digital
timer text field is added. where digital timers show hours, minutes and seconds. In buttons there
is up, down, right and left buttons is added which moves the car is different direction. In the
buttons there is option1,option2, option3 and exit button is added. there is compass added in other
button, which show direction of the car. In other panel there is three buttons is added, where in the
buttons there is Act, Run, Reset is added. there is also speed testing is added. There is also menu
bar. In the menu bar there is scenario, edit, controls and helps.

19436768 Pankaj Kumar Mandal 3 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

Figure 1.1: Emulation - CCarCrash.java Application – Opening State MacOSX.

1.1. Aim

When > button was pressed then car moves forward direction .

When >button was pressed then car moves backward direction .

When ^button was pressed then car moves upward direction .

When v button was pressed then car moves downward direction .

19436768 Pankaj Kumar Mandal 4 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

1.2. Objectives

The car should only move inside the area bounded by the two red walls.
If the come to contact with the bounded walls then the game will stop.
The car ought to move one whole black at every time, at movement key button through a
direction button (<, >, ^, v) is clicked in every time ( If movement is possible).
The scheme be must by the solution which is provided.
The completion of main solution must be done using the act button (accessing the drive car)
way within the car crush class.

Rules (More advanced)

From the given scenario we have Act, Run, Reset buttons in the third panel . when you press the act button
the car run one step forward in between two red wall, the car round the scenario. when you press the run
button car run automatically, when you pause the run button the car stop. When the reset button was pressed
the game again started.

19436768 Pankaj Kumar Mandal 5 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming
2. ANALYSIS

2.1. System Requirements: Essential (Graphical User Interface)

There are fourteen buttons used in the scenario . where four button is used for option 1 , option 2 , option 3
and Exit in second panel. In the option we have reached different level by the option ,where exit button close
the game . There are three button which is used in third panel, they are Act, Run and Reset . when we have
pressed the Act button the car run one step forward between the two walls .when we pressed the Run button
the car run automatically. When we pressed the Reset button the game again restart. In the second panel
there are nine buttons which is used run the car forward , backward ,upward and downward .this button is
used for move the appropriate direction by one square for each press. Where the symbol is(>, <, ^, v), where
the five button is blank. There is also compass icon button that should illustrate the current direction for the
car in the second panel . there is option , square and direction button. By the use of option button we reached
the different level option1 , option2,and option3 . where square button give the location of car. The direction
button was used for car of direction . In the second panel there is also a digital timer which is used for the
time of car run . this shown how much time be considered the car when its run. There are three text field
which show hours, minutes, and second. This whole panel is created in frame which size is 810 * 650. The f
tittle frame application name is set as CCarCrash.

2.2. System Requirements: Additional (Functionality & Complexity)

 Option button = show the different option of car


 Square button = show the location of car
 Direction button = show the direction of car run
 > button = move forward direction
 < button = move backward direction
 ^ button = move upward direction
 v button = move downward direction
 Option1 button = 1st level of game
 Option2 button = 2nd level of game
 Option3 v = 3rd level of game
 Exit button = end the game
 Digital timer = show the time of car run
 Compass button = show the car direction
 Act button = run one step forward
 Run button = move the car automatically
 Reset button = restart the game
 MenuBar = to show the menu

19436768 Pankaj Kumar Mandal 6 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming
3. DESIGN

3.1. GUI Design

Figure 3.1: Emulation - CCarCrash.java Application (Note: Opening State MacOSX).

19436768 Pankaj Kumar Mandal 7 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

3.2. Design (Pseudo-code/Flowcharts)

19436768 Pankaj Kumar Mandal 8 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming
4. IMPLEMENTATION

4.1 For maze

In this screenshot , we would show that how the panel is set. There are 3 panel add in the scenario
,they are panel1, panel 2 and panel3. Different panel had different size and there background colour.

19436768 Pankaj Kumar Mandal 9 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

4.2. Right key button function

This code to move car in right direction .this method name is set as can\move right. Right button is i.e. ‘>’.
When this button is clicked car run is right direction . and the compass show the car moves in east direction .

4.3. Left key button function

This code to move car in left direction .this method name is set as can\move left. Left button is i.e. ‘<’.
When this button is clicked car run is left direction . and the compass show the car moves in west direction .

19436768 Pankaj Kumar Mandal 10 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

4.4. Up move button function

This code to move car in up direction .this method name is set as can move upward. Up button is i.e. ‘^’.
When this button is clicked car run is upward direction . and the compass show the car moves in north
direction .

4.5. Down move button function

This code to move car in down direction .this method name is set as can move downward. down button is
i.e. ‘V’. When this button is clicked car run is downward direction . and the compass show the car moves in
south direction .

19436768 Pankaj Kumar Mandal 11 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

4.6. Act button function

When act button is pressed the car run one step forward in east direction

4.7. Run button function

When the run button is pressed the car run automatically in direction .and the compass also shown their
direction east , west, north and south respectively.

19436768 Pankaj Kumar Mandal 12 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

4.8. Reset button function

When the reset button is pressed the game restart .and start new game.

19436768 Pankaj Kumar Mandal 13 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming
5. TESTING

In this the whole scenario is tested to detect whether there is problem or not and limitations also and it is
done as giving some task and observing it and reporting it.

S.N Conditions Expected Output Actual Output


1. Right button is pressed i.e.(>) The car should run in The car run in east
forward direction direction
2. Left button is pressed i.e.(<) The car should run in The car run in west
backward direction direction

3. Down Key (V) is pressed The car should run in The car run in south
downward direction direction

4. Up key (^) is pressed The car should run in The car run in north
upward direction direction

5. Act button is pressed The car should run in Car run forward and
one step forward downward when there
direction is possible

6. Run Button is Pressed The car should run in Car run automatically in
automatically and their direction when
change their direction there is possible

7. Reset Button is pressed Scenario should come Scenario comes in


in default style default style

8. Exit Button is pressed Scenario must close Scenario close

19436768 Pankaj Kumar Mandal 14 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

6. CONCLUSION & RECOMMENDATIONS

On concluding the whole report, talking from introduction part, where author have stated and described
about the assignment and scenario. Introduction to the task describes the tasks which author have done. All
rules and basic, intermediate requirements are fulfilled. Each task is introduced and analyzed word by word.
The whole scenario is analyzed to detect problems and detected problem are solved. Complex parts are
made easy with the help of algorithms and flowcharts. Then whole scenario is taken to the testing portion
where it is tested with all the possible inputs to detect extra errors and limitations of code. Completing basic
requirement, the car run in all direction with the help of respective movement keys and finally reaches at its
destiny. Intermediate features like when the car touches the wall the car not move massage be shown The
extra features like functioning of act, run, reset button functions very well.

Here in this assignment all the requirements are fulfilled, however there are some limitations and weakness
that are still hidden inside code. Some of the limitations are non-function of Option2 and Option 3, menu
items, etc. If I had more time would have tried to solve them and add some advance features like game
sound, obstacles, function of option2 and option3 etc.

19436768 Pankaj Kumar Mandal 15 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

19436768 Pankaj Kumar Mandal 16 BSc computing


Year 1 (Level 4) CSY1020 – Problem Solving & Programming

7. REFERENCES

https://www.tutorialspoint.com/javaexamples/index.htm

https://www.eclipse.org

www.freebookcentre.net/JavaTech/javaCategory.html

http://math.hws.edu/javanotes/c7/index.html

http://math.hws.edu/eck/cs124/downloads/javanotes8-example-programs.zip

http://math.hws.edu/javanotes/source/index.html

19436768 Pankaj Kumar Mandal 17 BSc computing

You might also like