Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CMT120

Fundamentals of Programming

2022

This assignment is worth 100% of the total marks available for this module. If coursework is submitted late (and where there are no extenuating circumstances):

1.  If the assessment is submitted no later than 24 hours after the deadline, the mark for the assessment will be capped at the minimum pass mark;

2.  If the assessment is submitted more than 24 hours after the deadline, a mark of 0 will be given for the assessment.

Your submission must include the official Coursework Submission Cover sheet, which can be found here: https://docs.cs.cf.ac.uk/downloads/coursework/Coversheet.pdf

Submission Instructions

All coursework should be submitted via upload to Learning Central.

Description

Type

Name

Cover sheet

.pdf le

[Student number] .pdf

Task 1 source le

.py or .js le

[Student number] 1 .py [Student number] 1 .js

or

Task 2 source le

.py or .js le

[Student number] 2 .py [Student number] 2 .js

or

Task 3 source le: complete website code in one .zip le*

.zip

[Student number] 3 .zip

* More specific instructions on what you need to include in the .zip le for Task 3 are given in Section ’– Submission to Learning Central on p. 6.

Relative to Task 3, the following should also be pushed to the Schools GitLab server :

Complete project folder, which includes all directories and sub-directories, necessary for the project deployment. DO NOT push a single .zip le - instead, this should be     uploaded to Learning Central.

Any ’supplementary’ files, e.g. virtual environment or bytecode les or folders (venv, .git folders,  .pyc les, etc.), which are not vital for the deployment should be excluded.

Full instructions on what you need to push your project code to GitLab are found in Section ’– Submission to the Schools GitLab on p. 6. Please make sure you read these carefully.

Any code submitted will be run on a system equivalent to the laptops provided to the students,  and  must be submitted as stipulated  in the  instructions above.   The code should run without any changes being required to the submitted code, including editing of filenames.

Any deviation from the submission instructions above (including the number and types of files submitted) may result in a deduction of 25% for the corresponding task.

Staff reserve the right to invite students to a meeting to discuss coursework submissions.

Assignment

This coursework is comprised of three tasks which you need to complete for this assignment.

Task 1 - File System Display

Write a command line program that prints the directory and le system tree structure that originates in the current directory.  The algorithm used to explore the tree must be recursive. This task can be solved either in Python or JavaScript. Sample output:

./

----picture1 .png

----slideShow .pptx

----UniProject

--------doc1 .docx

--------doc2 .docx

--------old  files

------------doc1 .old

----personalstuff

--------holidays .xlsx

In the example, the current folder containts two les (i.e., ”picture1.png” and slideShow.pptx”) and two directories (i.e., ”UniProject” and personalstuff”). Directory UniProject” contains      two file (i.e., ”doc1.docx” and doc2.docx”) and one folder (i.e., ”old les”) with one le.      Directory ”personalstuff” contains only one le, i.e., ”holidays.xlsx” .

Task 2 - Amoeba Wars

Write a command line program that allows to play the game of Amoeba Wars for two human players. A description of the game is given below. This task can be solved either in Python or JavaScript.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

The game is played on a square grid. The rst player is O’ and the other is X’ . The game starts with an O’ amoeba in the bottom left corner, and an X’ amoeba in the top right corner (all the examples suppose a game played on an 8x8 board):

’O’ plays rst and has one move. Then, the players take turns in making three consecutive moves. Each move can be to:

Create a new amoeba, by writing the player’s symbol in an accessible empty cell, or

Kill one of the opponent’s amoebas in an accessible cell, by shading the cell.  A shaded cell is not empty and is not an amoeba.

A cell is accessible if it is next to one of the player’s live amoebas, horizontally, vertically, or diagonally.

For example, in the following opening rstly O’ played at B2, secondly X’ created three new Amoebaes (i.e., G7, F6, and E5), and nally O’ created two (i.e., C3 and D4) and killed one of X’s (i.e., E5):

A player must make all of their moves in a turn.  The game ends when a player cannot make all the moves.  The score of a player is the number of live amoebas they have when the game ends, plus the number of opponent’s amoebas killed. The player with the highest score wins.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Your program should allow to play a two-players game of Amoeba War from the command line.  Initially, the game asks for the size of the board.  The board must be square (e.g., 6x6, 7x7, 8x8).  Once the size has been entered, the initial board is drawn and the O’ player starts. The drawing displays the board, the column and row references (i.e., A, B, C,... and 1, 2, 3,..., respectively), and the current score on top of the board, as illustrated (supposing an 8x8 board):

O  01  -  01  X

------------------

8

7

6

5

4

3

2

1

|  |  |  |  |  |  |X

|  |  |  |  |  |  |  |

|

|

|

|

|

|  |  |  |  |  |  |  |  |

------------------

|A|B|C|D|E|F|G|H|

On each turn, the program informs the current player of the moves left and provides a list of feasible moves. For example, the feasible moves for player O’ in the above board are:  A2, B2, and B1.  The players can make their moves one at the time by entering the coordinates of the chosen cell (e.g., A2).  The program recognises invalid moves and informs the player in case of a mistake.  After each move, the program draws the state of the board, informs the current player of the moves left, and provides a list of feasible moves.  Finally, the program recognises when the game is over and a message is displayed to show the nal score and congratulate the winner. After that, the program asks if the players want to play another game.

Task 3 - Website on Security, Quality and Usability

For this task, develop a website, which provides your visitors with information on security, quality and usability.

Your website should  be developed  using  Flask 1 and SQLite database,  and  have a number of pages to display content to visitors. Each web page should have:

- header with navigation bar to enable the visitors to access all pages;

- section that displays the main content, appropriate for each page;

- footer containing relevant links to additional information, e.g. contact details, privacy policy, disclaimer, etc. ;

- you can also include a side bar to display any information you think is relevant and makes your website more attractive and usable.

More specically, your websites organisation and functionality should be as follows:

1. Home page should allow visitors to:

see a preview of each individual page available on your website - the preview should contain a title, image and a short summary of each page (3-4 lines);

access each individual page by click on each pages title or image;

access login or registration pages (see explanation of content and functionality of these pages later);

see personalised greeting in the top navigation bar if they are logged in, e.g.    a logged in customer will be greeted by their rst name (e.g. ’Hello,  Jane!’).    The visitor, who is not registered or logged in will see Hello,  Guest!’ message.

2. TWO individual pages - one page for the topic of Security, and one for Quality and Usability .

It’s up to you to decide on the actual content on these pages, but it is expected that for each topic your present:  a brief explanation of main aspects of the topic, best practices in the industry, and your own reflection based on your experience in developing software systems.

NB: You are allowed to use external sources for some of the content, but full references must be provided.

Each individual page should allow a registered visitor to leave a comment.

Additional web pages on each topic are allowed, but will not attract additional marks.

3. Registration page, which should:

Display a registration form, which asks the the visitors, who wish to register, to provide their rst and last name, email address (which will they use to log in) and password.

Perform a simple check that the visitor input their email address in the expected format, e.g. my email@some domain .com.

Note : this should be a simple check for the email address format - there is no need to check if this email address actually exists.


On successful registration: your website should redirect to the Home page, and display a message to the newly registered user confirming the registration succeeded.

If registration is unsuccessful: the system should display a meaningful error message, and will not redirect to any other page.

4. Log in page, which should:

Enable a registered visitor to log in, and if successful, the visitor is redirected to the home page.

Display an error message if there is a problem with a visitor’s login. NB: make sure that error messages do not jeopardise your website’s security.

Allow a logged-in user to log out.

Submission Instructions for Task 3

For Task 3, you need to submit your work to two places: Learning Central AND GitLab, as follows:

Submission to Learning Central

This must be a single .zip archive that includes the complete source code of your website, including:

README.txt (or README.md) file, which includes: your student number, and specic instructions on how to run your website from the command line.   You may also include any other information you consider relevant to your submission.  Any references that are not on your website should also be included here.

requirements.txt le, which contain a complete list of all python packages required to run your website project.

Your SQLite database.

All files need to be in appropriate folders so that your website can be compiled without any need to modify les or folders, e.g. the actual web pages in templates folder, images, JS, CSS les in appropriate subfolders of static folder, etc.

Submission to the Schools GitLab The School’s GitLab server is located at https: //git.cardiff.ac.uk/.

All project code should also be pushed to a repository on our School’s GitLab server. You will then need to share your GitLab repository with Federico Liberatore and Natasha Edwards as follows:

s  Click on Members’ on the left sidebar.   This will open Project members’ page.

s  In GitLab member or Email address’ field, search for Federico Liberatore (username: scmfl2)

s  In Choose a role permission’ field, select Maintainer from the dropdown menu.

s  Click Invitebutton to conrm.

s  Repeat the above steps for Natasha Edwards (username: scmne), making sure the role permission is also set as Maintainer.

NB: You must use the Schools GitLab, using external git servers is not allowed.

Learning Outcomes Assessed

LO1: Use high-level programming languages to complete programming tasks

LO2:  Demonstrate familiarity with programming concepts, simple data-structures and algorithms

LO3: Design and use relational databases

LO4: Develop secure web applications

LO5:  Critically evaluate the role of security, quality and usability within software projects

Criteria for assessment

Credit will be awarded against the following criteria, depending on the task.

Functionality: Does the code perform the required task correctly, accurately, and efciently?

Code quality: Is the code elegant and well-written; simplified by the use of built-in languages features where appropriate; readable; commented? Are appropriate functions defined  and written to enable reuse? Are classes defined and used effectively?

Usability: Is the navigation intuitive, consistent, and self-explanatory? Do all the pages  have clear navigational menus that provide access to all other pages without breaking the logic of operation?

Presentation and content: Is the website professionally presented? Is the content laid out logically and consistently? Are HTML and CSS used effectively? Is the content high-quality?

The mark breakdown for each part is given in the following.

Task 1 [Total: 20 marks]

Functionality: Recursive denition. 5 marks

Functionality: Output as expected. 5 marks

Functionality: Program correctly displays the directory and le tree structure of the current directory. 5 marks Code quality. 5 marks

Task 2 [Total: 20 marks]

Functionality: User interface. 3 marks

Functionality: Game ow. 6 marks

Functionality: Feasible moves. 4 marks

Functionality: Ending condition and score calculation. 4 marks

Code quality. 3 marks

Task 3 [Total: 60 marks]

Functionality:  programmatically generated content (i.e.  pulled from the database, not hardcoded’ manually). 5 marks

Functionality:  Home page. 8 marks (content displayed correctly - 2, access to individual pages - 2, access to registration and login - 2, personalised greeting - 2)

Functionality:  Individual pages. 20 marks (for each page:  content - 6, ability to leave a comment - 2, comments displayed correctly - 2)

Functionality: User registration. 12 marks (registration form - 2, input validity check - 2, on valid input user account created - 2, confirmation message - 2, redirect to Home page - 2, on invalid input error messages displayed - 2)

Functionality: User login and logout: 5 marks (successful login - 2, error messages on invalid input - 1, logout - 2)

Usability and design/presentation: 10 marks