联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> javajava

日期:2018-11-18 09:10

COMP1405A (Fall 2018)"Introduction to Computer Science I"

Specification for Assignment 5 of 6

Your submission for this assignment must include your full name (as it appears on cuLearn)

and you nine-digit student number as a comment at the top of every source file you submit.

Your submission for this assignment must be a single source file with a file name of

'comp1405_f18_#########_a5.py' (with the number signs replaced by your nine-digit

student number). It must also be written using the Python 3 programming language, and

must run on the official virtual machine.

Do NOT compress your submission into a "zip" file.

Late assignments will not be accepted and will receive a mark of 0.

Submissions that crash (i.e., terminate with an error) on execution will receive a mark of 0.

The due date for this assignment is Saturday, November 17, 2018, by 11:00pm.

For this assignment, you will create a program that allows users to work with cryptograms.

Your program must be completely organized into a collection of functions described by

this document, and your program is not permitted to use any global variables whatsoever.

To accomplish this, you will need to pass elements of data back and forth between

functions using arguments and return values.

COMP1405A (Fall 2018) ? "Introduction to Computer Science I"

Specification for Assignment 5 of 6

You must start with a main function that takes no arguments and produces no return

values. Additionally, as the very last line of your program, you must call this main function.

You will notice that this function is preceded by a multi-line comment that has been wrapped

in triple single quotation marks. You are required to write a comment like this for each

of the functions you create for this assignment. This comment must begin with a short

description of what the function does, contain a list (labeled @params) of indented items

corresponding to the parameter variables you use to hold your function arguments, and

contain a description of any return values (labeled @return). If the function you are writing

has no params or returns, then you must still include the @params or @return tag and write

(and indent) the word none.

Failure to observe this requirement will result in a penalty.

Much of your program will be written into the function definition of that main function. This

function is expected to provide a basic interface to the user. Your user should be able to use

the menu to select an option and your program will call the corresponding function

(and input if necessary). This will allow your user to load/save files and generate custom

alphabets for encryption or decryption.

Every time your user sees the main menu you must display for them:

a) the "initial" unmodified text last loaded by the load function (initially empty)

b) the "current" text that your program most recently created by enciphering or

deciphering

c) a list of options from which the user will select their next step, including at least

saving a file, loading a file, defining an alphabet, enciphering, and deciphering.

Please note that in order for you to be able to complete all of the functions specified on the

following page, your main function must have at least three variables, for storing 1) the

"initial" unmodified text, 2) the "current" text being modified by the user, and 3) the

current alphabet being used for enciphering and deciphering.

A flowchart explaining some of the functionality expected is included on the following page.

COMP1405A (Fall 2018) ? "Introduction to Computer Science I"

Specification for Assignment 5 of 6

You must write a function for "loading" data. It must receive one string argument and

produce one string return value. The argument will be the name of the file to be loaded and

the return value will be the entire body of text contained in the file. This function must not

crash if the user specifies an invalid filename (i.e., you must handle this exception) and

must, instead, return an empty string.

You must write a function for "saving" data. It must receive two string arguments and

produce no return value. The arguments will be the name of the file to be saved and the text

to be saved in the file, respectively.

You must write a function for "enciphering" data. It must receive two string arguments

and produce one string return value. The first argument will be the text to be enciphered,

and the second argument will the be alphabet to be used for this enciphering. The return

value will be the enciphered text. Consider the following example for clarification:

You must write a function for "deciphering" data. It must receive two string arguments

and produce one string return value. The first argument will be the text to be deciphered,

and the second argument will the be alphabet to be used for this deciphering. The return

value will be the deciphered text. Consider the following example for clarification:

COMP1405A (Fall 2018) ? "Introduction to Computer Science I"

Specification for Assignment 5 of 6

You must write a function called cryptogram_alphabet. It must receive no arguments

and produce one string return value. This function will use input to ask the user to type an

alphabet (i.e., type the 26 letters of the English alphabet in any order). If the argument

contains all 26 letters then the argument, converted to uppercase if necessary, then it is the

return value. If, on the other hand, the input does not contain all 26 letters or contains

duplicate letters, you will print an error message and return the unmodified alphabet

"ABCDEFGHIJKLMNOPQRSTUVWXYZ".

Your solution must not import any libraries, but you are free to use any of the following

functions from the standard library: list, range, upper, str, input, open, read, close, ord,

chr, print, len, and also int, insert, append, and pop.

Your program must not use any of the string processing functions. This includes, but is

not limited to, find/rfind, index/rindex, replace, sort, strip, split, translate or the built-in

encode or decode functions. If you want to use these functions then you will need to

write them yourself from scratch.

Your solution may use the indexing operator (i.e., you can use a[x] to get the element of a

list or string that is located at index x) but your solution must not use the slicing operator

(i.e., you cannot use a[x:y] to access the elements of the list or string that have indices

between x and y-1).

Your solution must not use list comprehensions in any way.

Your solution must not use dictionaries or maps in any way either.

This program (along with any other program submitted in this class) must be a completely

original work, authored by you and you alone, prepared for this offering (i.e., Fall 2018) of

COMP1405. Do not discuss this assignment with anyone except the instructor or the teaching

assistants, and do not copy images or source code samples from the internet or any other

source.


版权所有:留学生程序网 2020 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。