Programming Principles (Python)

The assignment entailed using the python Turtle library to draw an interactive forest simulation application. Turtle is a graphics library in python that allows drawing of images of the canvas(Vidal,2016). The application should allow the user to draw in different positions of the screen, either bird icons or tree icons. This is done when they choose the kind of image they want, e.g. bird and click at the position.

The implementation of the project has prerequisites which must be met for it to work as expected.

One of them is a Python programming language installation. Python is easy to learn a high-level programming language(Srinath,2017). This can be found at Python official website at www.python.org.

You also need the Python Turtle module. These can be installed using the Python Package Manager called Pip or Pip3 for Python version 3. A package manager is a command that enables users to install and manage packages written by other programmers in a particular programming language(Muhammad et al.,2019). The Turtle Package can be installed with the command:

python3 -m pip install PythonTurtle

 

The project was designed using a top-down approach. This involved decomposing the program into smaller, manageable functions and objects. The program was first divided into two classes to be implemented, Draw for drawing the tree and bird icons, and Forest, which finally achieved the forest simulation functionality. The classes were further decomposed into different methods and properties which carried out different feature. This made development easier since you could focus on one function at a time without worrying about other parts of the program(Goschnick,2018).

 

Different design techniques were also applied. Most outstanding of them was the use of flowcharts in the design of some of the functions that were employed in the program. A flowchart is a pictorial model of how program execution should start, proceed and end(Herrera-Camara,2017). The following is a flowchart for the handle_click() function that was implemented in the program.

 

 

 

Testing is essential in software development to eliminate errors and failures that could be caused by the program. It also assures users that the program is working as expected.

 

Several test cases were developed to test the program functionality.

Test Data Table
Test data

type

Test

data

The reason it

was selected

The output expected

due to the use of the

test data

The screenshot of actual

output when the test data is

used

Normal User clicks inside boundary margins To show that either tree or bird icon is displayed Either tree or bird icon is displayed
Normal User clicks on tree’s circle To show that turtle changes to a tree Clicking inside boundary displays tree icon.
Normal User clicks on bird’s circle To show that turtle changes to bird Clicking inside boundary displays bird icon
Normal User clicks left

arrow keyboard key when bird icon selected

To show that the angle of the turtle changes The angle of turtle icon changes anti-clockwise
Abnormal User clicks on “up” keyboard key To show that the

“up” keyboard key does not change application state

No action is undertaken.
Abnormal User clicks on “b” keyboard key To show that the

“b” keyboard key does not change application state

No action is undertaken.
Abnormal User clicks outside boundary margins To show that

clicking outside boundary margins does not initiate action

No action is undertaken.

 

 

The program was implemented successfully using the Python3 programming language. All the objectives were also met.

Vidal Duarte, E. (2016, July). Teaching the First Programming Course with Python’s Turtle Graphic Library. In Proceedings of the 2016 ACM Conference on Innovation and Technology in Computer Science Education (pp. 244-245).

 

Srinath, K. R. (2017). Python–The Fastest Growing Programming Language. International Research Journal of Engineering and Technology (IRJET), 4(12), 354-357.

 

Muhammad, H., Real, L. C. V., & Homer, M. (2019, October). Taxonomy of Package Management in Programming Languages and Operating Systems. In Proceedings of the 10th Workshop on Programming Languages and Operating Systems (pp. 60-66).

 

Goschnick, S. (2018). A Design Method for People-Oriented Programming.

 

Herrera-Camara, J. I., & Hammond, T. (2017, July). Flow2Code: from hand-drawn flowcharts to code execution. In Proceedings of the Symposium on Sketch-Based Interfaces and Modeling (pp. 1-13).