首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
辅导 program、讲解 python设计程序
Important: when running your assignment as python3 a5.py the GUI should load automatically.
In your final project, you will build upon and extend what you have learned in the course and what you completed in your assignments. In assignment 5, you will integrate multiple aspects of what you have learned in the class to create a complete software product!
For your final assignment, you will develop a module that enables a program to send and receive direct messages to another user on the DSP platform. You will then incorporate this module into a graphical user interface (GUI) using Tkinter that should allow any student to communicate with any other student in this class as long as they know each other usernames.
To help you get started, the requirements for your final program have been divided into different parts. You are encouraged to follow each part in order. Note that each part can be written and tested independently.
Very important: do not wait until near the deadline to start this project, as you will certainly not have time to complete it if you do so, and this project deadline will not be extended.
Part 1: Implement the Direct Messaging Protocol
To communicate with another user on the DSP platform, your program will need to use new protocol messages. To support these new messages, your program must extend your ds_protocol module to support direct messaging with the following commands:
directmessage
Accepts a message to be sent directly to another user. The username is passed in the "recipient" part of the command. Also retrieve messages from the server. Example:
# Send a directmessage to another DS user (in the example bellow, ohhimark)
{"token":"user_token", "directmessage": {"entry": "Hello World!","recipient":"ohhimark", "timestamp": "1603167689.3928561"}}
# Request unread messages from the DS server
{"token":"user_token", "directmessage": "new"}
# Request all messages from the DS server
{"token":"user_token", "directmessage": "all"}
Recall from a3 that user_token is retrieved by sending a successful join command. So to send a direct message, you must first join the server and retrieve the token that you must later use.
The DS server will respond to directmessage requests with the following ok response messages:
# Sending of direct message was successful
{"response": {"type": "ok", "message": "Direct message sent"}}
# Response to request for **`all`** and **`new`** messages. Timestamp is time in seconds
# of when the message was originally sent.
{"response": {"type": "ok", "messages": [{"message":"Hello User 1!", "from":"markb", "timestamp":"1603167689.3928561"},{"message":"Bzzzzz", "from":"thebeemoviescript" "timestamp":"1603167689.3928561"}]}}
To process these new response messages, you will need to extend the message conversion code that you wrote for a3. How you solve this requirement is up to you, but a good approach will likely include adding a function to your ds_protocol that converts JSON messages to a list or a dictionary.
Writing a Test
When your code is complete, write a small test program to verify that your messages are processed as expected. Your program should import your module (e.g., import ds_protocol, if you are extending your ds_protocol module) and call the code you have written with a few test messages. You can use the messages provided as examples above or create a few of your own as test cases. You can name your test whatever you like, but it should be prepended with the word test_:
test_ds_message_protocol.py
Once your test program is complete, you can move on to the next part of the assignment.
Part 2: The DS Direct Messenger Module
Now that you have a functioning protocol, you can write your message send and retrieve code. The first thing you will do is complete the direct messenger module. Your module must adhere to the following rules:
It must be named ds_messenger.py
It must implement the following classes and methods
class DirectMessage:
def __init__(self):
self.recipient = None
self.message = None
self.timestamp = None
class DirectMessenger:
def __init__(self, dsuserver=None, username=None, password=None):
self.token = None
def send(self, message:str, recipient:str) -> bool:
# must return true if message successfully sent, false if send failed.
pass
def retrieve_new(self) -> list:
# must return a list of DirectMessage objects containing all new messages
pass
def retrieve_all(self) -> list:
# must return a list of DirectMessage objects containing all messages
pass
You are free to add as many supporting methods to either of these classes as you need, but the ds_messenger.py module must be able to function without any other dependencies. A program that imports your module should be able to call the required functions to exchange messages with the DS server. You may reuse or import the code you have written for the ds_client.py module to reduce the amount of code you have to write here!
Writing a Test
Once again, when your code is complete, write a small test program to verify that your ds_messenger module is functioning correctly. You can name your test whatever you like, but it should be prepended with the word test_:
test_ds_messenger.py
Once your test program is complete, you can move on to the next part of the assignment.
Part 3: Store Messages Locally
Some of the data your program uses should be preserved across multiple users. To complete this feature, you can either implement your own data storage code or, what can be more straightforward, extend the Profile module to support serializing new data.
Your program should be able to store message data locally so that when the program starts, it does not have to connect to the DSP server to display new messages. Your program should also store recipient data locally so that your user does not have to add the same recipients each new time the program is run (for instance, you can create a new attribute in Profile containing list of "friend" usernames). It’s OK if you require a user to first load their dsu profile (or any other custom file format you build) before displaying data. The important thing here is to NOT require an internet connection to get messages that were already previously retrieved.
However you handle this requirement, after using your program once, all recipients who were previously added and all the messages that were previously retrieved by the user, should appear in your GUI (see Part 4) when it starts at any subsequent use.
Part 4: The Graphical User Interface
The final part of the assignment will be to write a graphical user interface (GUI) for your module using Tkinter. You are free to implement the interface however you like or to adapt the Tkinter GUI starter code that you were given in assignment 5.
There are many ways to create a graphical interface for a direct messaging program. You are not required to follow the example below. However, if you are unsure where to start, the following wireframe should point you in the right direction.
In the wireframe model presented above, there are 5 widgets which are responsible for all of the input and output in the program:
1.On the left is a treeview widget that displays all of the DS users that have sent you messages. Selecting a user must display the messages that they have sent in (2).
2.On the upper right is the display widget that contains the messages sent by the user selected in (1).
3.On the lower right is the text input widget where new messages are written.
4.The ‘Add User’ button adds new contacts (recipients) to receive direct messages.
5.The ‘Send’ button sends the message entered in (3) to the user selected in (1).
A small help: The layout used in this wireframe is nearly identical to the layout provided to you as an example code in this link Download example code in this link. You may reuse this existing code to save you some steps, but if you decide to use this code instead of writing your own interface from scratch, you must to modify it a bit (for instance by moving some options around, adding new options, or a new design, reconfiguring the way that the messages are printed by adding color, etc.) and you also need to finish implementing it, as the provided code is not fully operational.
One possible version of the Social Messenger app is pictured above. In this version, the add user requirement has been moved to the settings menu.
In addition to the requirements described above, there are a few other tasks you must do to complete the assignment:
1.Your GUI must automatically retrieve new messages while the program runs (see the after method to create timed events in tkinter, as we covered in week 9).
2.Your conversations must be visually separated in some way between the different students (e.g., left/right align, color, identifier, etc; if you are using a tkinter text widget, look for how to use tags with the text insert methods).
3.Selecting a new contact in the treeview should display any recent messages with that contact in the message window (e.g. you will need to clear the text box contents and then insert the previous messages of the selected user).
What to submit?
You are free to design your code as you wish as long as you respect the assignment's requirements above and the standing requirements for assignments of the course (usage of git/style/exceptions/unitests/README; see important reminder notes below). After you finish developing and testing your code, submit your assignment on canvas.
You will submit to Canvas your entire code, including your .git local repository, and a simple README file that includes a simple description in English in one or two paragraphs of what your software does in your own words. You must compress your entire project using zip (from linux, if you are inside your project folder, you just need to write zip -r Assignment5.zip . and you should produce the correct file to submit (mind the space and the dot after the file name; that means that you want to include all files, including hidden files, as the git repo folder, inside the compressed file).
You must respect the following simple file structure for this project:
Assignment5.zip
.............. README.txt
.............. a5.py
.............. ds_protocol.py
.............. ds_messenger.py
.............. test_ds_message_protocol.py
.............. test_ds_messenger.py
..............
.py
.............. .git/...
You must put your main() function (and obviously your if __name__ == "__main__": code) inside the a5.py file.
No late submission for assignment five will be allowed.
Important reminder notes: as usual in a professional code development scenario, you are required: to keep track of your development using git with regular commits, as we previously saw in the quarter; to respect PEP8 Python coding styles; to add a simple but descriptive README file; and to deal with possible exceptions and errors that may happen. You will not get additional points for respecting these software development requirements, but penalties in the assignment are associated with not following them, as you would be producing lower-quality software.
1. On the number of commits to your local git repository: if you have a single commit, you may get no grade; you do need to have several commits to demonstrate how you wrote your assignment and how you solved bugs, etc., during your development. As a rule of thumb, for this assignment, we expect you to have at least as many commits as you have functions/classes/methods defined in your code, but usually, you will possibly have many more. If you have one single commit where you commit your entire code to your local repository, we will consider that you have no commit at all.
2. On the coding style: before submission, make sure to check your style and possible code mistakes using pycodestyle and pylint as seen in lecture, and make all the necessary changes, including in any starter code provided to you, as they include simple style issues for you to correct. It should be simple to fix most of the code issues, thus respecting PEP8, if you address the pycodestyle and pylint errors and warnings, thus avoiding any penalty.
3. On testing: it is expected that your assignment 5 code will include unit tests for the most important functions/methods/classes. Make sure that you develop these test cases to be compatible with pytest.
Rubric
A5
A5
Criteria Ratings Pts
This criterion is linked to a Learning OutcomeAuto-graded functionality requirements: DirectMessenger
Can you instantiate the DirectMessenger as specified in the assignment prompt? 3 pts
This criterion is linked to a Learning OutcomeAuto-graded functionality requirements: send() method
Does send() work AND return True/False as specified in the assignment prompt? 3 pts
This criterion is linked to a Learning OutcomeAuto-graded functionality requirements: retrieve_all() method
Does retrieve_all() work AND return a list of DirectMessage objects as specified in the assignment prompt? 3 pts
This criterion is linked to a Learning OutcomeAuto-graded functionality requirements: retrieve_new()
Does retrieve_new() work AND return a list of DirectMessage objects as specified in the assignment prompt? 3 pts
This criterion is linked to a Learning OutcomeUser interface functionality requirement: organization
How organized is the User Interface? (i.e., how easy and clear is the user interface? can someone use it without thinking too much/reading the manual/reading the code?) 2 pts
This criterion is linked to a Learning OutcomeUser interface functionality requirement: sending messages
Does the graphical user interface allow someone to send a message to another user? Is this functionality working properly? 2 pts
This criterion is linked to a Learning OutcomeUser interface functionality requirement: message display
Does the graphical user interface clearly distinguishes between messages that were sent to and received from other users? 2 pts
This criterion is linked to a Learning OutcomeUser interface functionality requirement: retrieve new messages automatically
Is the graphical user interface automatically retrieving new messages from the server? (i.e., when someone sends you a message, is this message displayed in your user interface automatically after a few seconds?) 1 pts
This criterion is linked to a Learning OutcomeUser interface functionality requirement: history display
Does the graphical user interface automatically displays previous messages exchanged with another user (i.e., "friend", "contact", etc.) when this user is selected in the interface? 1 pts
This criterion is linked to a Learning OutcomeDesign, development, and documentation requirements: existence and naming
Does the code exists and if it is properly named as required in the assignment prompt? 3 pts
This criterion is linked to a Learning OutcomeDesign, development, and documentation requirements: README
Does your code come with a README file? 0.5 pts
This criterion is linked to a Learning OutcomeDesign, development, and documentation requirements: coding style standards
Is your code following PEP8 standards? 3 pts
This criterion is linked to a Learning OutcomeDesign, development, and documentation requirements: git
Have you followed the course requirements for git usage during the development? 1.5 pts
This criterion is linked to a Learning OutcomeDesign, development, and documentation requirements: possible issues
Is your code being flagged for any possible quality issue by standard static code analysis tools (pylint)? 3 pts
This criterion is linked to a Learning OutcomeDesign, development, and documentation requirements: testing
Have you implemented unit tests and is the code coverage of your test suite reasonable as specified in class? 4 pts
Total Points: 35
v
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
讲解 econ1202 – quantitativ...
2024-11-22
辅导 msds 490: healthcare an...
2024-11-22
讲解 civl 326 geotechnical d...
2024-11-22
辅导 term paper medicine whe...
2024-11-22
讲解 eng3004 course work辅导...
2024-11-22
讲解 ee512: stochastic proce...
2024-11-22
辅导 geog100 ol01 - fall 202...
2024-11-22
辅导 st5226: spatial statist...
2024-11-22
讲解 ece 101a engineering el...
2024-11-22
讲解 database development an...
2024-11-22
讲解 comp3134 business intel...
2024-11-22
讲解 practice exam 2, math 3...
2024-11-22
讲解 project 4: advanced opt...
2024-11-22
辅导 38003 organisational be...
2024-11-22
辅导 economic growth调试spss
2024-11-22
辅导 ee512: stochastic proce...
2024-11-22
讲解 eesb04 "principles of h...
2024-11-22
辅导 am2060 final assignment...
2024-11-22
辅导 acfim0035 fundamentals ...
2024-11-22
辅导 stat 612 (fall 2024) ho...
2024-11-22
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!