代写Assignment 4 - Emoji Carousel帮做Python编程

Assignment 4 - Emoji Carousel

Due Date: April 8th, 2024 at 23:55

Percentage overall grade: 5%
Penalties: No late assignments allowed
Maximum Marks: 100

Pedagogical Goal: Refresher of Python and hands-on experience with algorithm coding, input validation, exceptions, ANSI escape codes, queues, doubly linked lists and data structures with encapsulation.

Read the whole document before starting to solve the Assignment problem.

Submit only your work. While you can collaborate and help each other, do not share code. If you collaborate, acknowledge your collaborator in the code comments.

Follow the Software Quality Requirements.

Assignment Specifications:

Assignment 4 FAQ
Problem: Emoji Carousel

You are an employee at Zoogle Inc., and fortunately, you are part of an R & D team responsible for creating blueprints for various features of their popular operating system. They never had a “Circular Image Carousel” feature built into their OS. Your job is to create a bare-bones interpretation of that idea using a Circular Doubly-Linked List.

For this assignment, instead of images, you will use emojis from a JSON file (Remember them from CMPUT 174? Refer to the refresher at the bottom of the assignment description).

Each element of this carousel will be a doubly-linked list node, which will have a reference to the next/”right” node, previous/”left” node, and data about what is in that node.

The doubly-linked list node class should have methods to:

1. Initialize the attributes of the class

2. Retrieve the data stored in it

3. Change the data stored in it

4. Get the previous/left node

5. Get the next/right node

6. Set the previous/left node

7. Set the next/right node

Any other required methods can be created as per your needs. Appropriate Exceptions should be raised if necessary.

Your carousel will be a fixed-length modified doubly-linked list — Going right/next on the last element will take you back to the first one, and going left/previous on the first element will take you to the last element. There are multiple ways to create an efficient class for this, but the class should have methods for initializing, adding a node, removing a node, and getting the active/current node. Initializing proper attributes is also based on your understanding of the project. The class should be named CircularDoublyLinkedList or DoublyLinkedList.

You have to create a visual depiction with shapes and emojis. For this task, you will use a dataset of emojis in a JSON file and a art.txt file with the shapes you need in order to create a visual representation.

The art.txt file has the ASCII art needed for the visual representation. All the figures are essential and should be present in your version of art.py as they handle different cases of visual representation of the carousel. With slight modifications and formatting, you can put emoticons in the place of “().” (Hint: You might need to look up how to print symbols which are part of escape sequences)

Remember that you are not required to read this .txt file; copy-paste the content into a new “art.py” file and create appropriate functions for use in the carousel.py file.

To use the JSON file, import the JSON module in your carousel.py file, read the file with the appropriate encoding, and extract the data into a suitable data type for further use.

User Interface Implementation

You must implement the following methods in the Carousel class:

· add: Responsible for adding a new node to the circular doubly-linked list.

· goLeft and goRight: Functions to navigate the carousel by moving to the previous or next node.

· delete: Removes the current node from the carousel.

· getInfo: Retrieves and displays information about the current node, including its Name, Symbol, and Class.

· quit: Allows the user to exit the program at any point.

Remember to Initialize the circular doubly-linked list with a compulsory attribute max_size. This max_size should be a constant of value 5.

Additionally, here is the scenario to keep in mind:

1. Initially, when there’s nothing in the carousel, the user will be prompted to enter “ADD” to add a node or “Q” to quit.

Type any of the following commands to perform. the action:

ADD: Add a emoji frame.

Q: Quit the program

>> add

What do you want to add?

>> tiger 

1. After the first addition, the carousel will be displayed with only one frame. with the emoji. Again, the user will be prompted to enter an input with two additional options, specifically “DEL” for delete and “INFO” for information.

 

1. The user can go left or right after adding the second frame.  Two more options: L: Move left and R: Move right will now be included in the menu.  The carousel will display three frames, the left frame. being the previous node and the right frame. being the next node. 
Note: Upon entering the emoji for the second node, your output shows the first node on both the leftmost and rightmost sides, with the second one in the center. This is so because our doubly-linked list wraps around. Please note that your double-linked list data structure DOES NOT have duplicate nodes.  

 

1. As more nodes are added, moving left and right should work endlessly as the list wraps around i.e if we were to move left, our display would look like as follows:

 

1. Deletion of nodes works the same; if more than one node is in the list, the display should have three frames; only one frame. should be visible when only one frame. is left.
At most 3 frames should be displayed: the current frame, one on the left and one on the right.

2. The current (↓↓) always points to the middle frame. that is being displayed.  If delete is chosen, the current frame. will be removed from the doubly linked list and not displayed. The new current frame. would be the one on the left. If the frame. removed were the only one left in the carousel, no frame. would be displayed, just like when you run your code the first time.

Addition of Nodes

There are two scenarios for adding nodes to the carousel:

Adding a Node when the Doubly Linked List is Empty:

· In this case, no specific input is required from the user regarding the insertion position.

· The first node is added directly.

Adding a Node when there is more than one node in the Doubly Linked List:

· Users can navigate the carousel using the goLeft and goRight methods to change the current node.

· After positioning to the desired node, the user is prompted to specify whether they want to insert the new node to the left (L) or right (R) of the current node. If the carousel has available capacity, the selected emoji is inserted at the chosen position.

· However, if the carousel is at full capacity, an exception should be raised with the message "You cannot add emojis! Carousel is Full."

Please follow this scenario to understand the process of inserting a node.

1. The user must add nodes. The user should be able to search the emojis using their names. (In the example below, the user is searching for a tiger emoji)

 

1. Check if the word entered by the user exists in the emojis' names. If not, then prompt the user again to enter a word.

(Optional-will not be marked) For a slightly advanced way to find the emoji that matches the word entered by the user, you can implement the pseudo spell checker based on Levenshtein distance. Your task is to find the emoji's name out of the JSON data closest to the user input and then confirm if that’s the emoji the user is looking for.

 

1. Once the emoji matches the word, the relevant data (Class, Symbol, Name; not precisely in this order) should be retrieved and added to the new node.

2. This new node should be added to the appropriate location per user inputs. The first node should be added without asking the user for location, as there’s nothing inside the list. If the list is not empty, the user should be prompted to specify left or right so that the node can be added to the left or right side of the current/active node.

Example of Node being added the first time:

Example of a Node being added the second time onward:

“DEL” is supposed to remove the active/current node. After a successful deletion, the current node will be the one to the left of the deleted node.

As previously stated, “INFO” stands for information, and that’s what it’s supposed to display. The information of the node should be presented in the following order: Name, Symbol, and Class. After showing the information, the user should be prompted to press any key to move forward. There should be a brief time gap of 1 second between the information display and asking for input.

You must use the os and time modules to make the demonstration presentable and less cluttered. You can use a time delay of one second to create an illusion of loading and clear the screen after executing commands of a functionality.

Here is a video demonstration:

Notice the pauses in the video. Those are the points where you have to implement the time delays. Also, make a note of the screen clearing and mimic the visual representation to the best of your ability.

JSON Refresher

This section serves as a short introduction and/or refresher to JSON. In Python, you can work with JSON data using the json module. It provides a way to encode and decode JSON data, allowing you to convert between JSON text and Python data structures. In this example, we will read from the following Pokémon JSON:

{

  "name": "Pikachu",

  "type": "Electric",

  "abilities": ["Static", "Lightning Rod"],

  "stats": {

    "hp": 35,

    "attack": 55,

    "defense": 40,

    "speed": 90

  }

}

To parse this JSON data, you can use the json.load() function to read the data directly from the file and store it in a dictionary (assume the JSON data is stored in a file named pokemon.json):

import json

with open('pokemon.json', 'r') as file:

    pokemon = json.load(file)

    print(pokemon['type'])

    print(pokemon['stats']['attack'])

After executing the above code, “Electric” and “55” are printed to the terminal. This is information directly from Pikachu’s JSON data entry.

Additionally, look up json.loads function on google if you want to learn more.


热门主题

课程名

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
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图