Concept explainers
TO DO: Code connection servers for all phones
code:
"""
HYPHEN = "-"
QUIT = 'quit'
SWITCH_CONNECT = 'switch-connect'
SWITCH_ADD = 'switch-add'
PHONE_ADD = 'phone-add'
NETWORK_SAVE = 'network-save'
NETWORK_LOAD = 'network-load'
START_CALL = 'start-call'
END_CALL = 'end-call'
DISPLAY = 'display'
def connect_switchboards(switchboards, area_1, area_2):
pass
def add_switchboard(switchboards, area_code):
pass
def add_phone(switchboards, area_code, phone_number):
pass
def save_network(switchboards, file_name):
pass
def load_network(file_name):
"""
:param file_name: the name of the file to load.
:return: you must return the new switchboard network. If you don't, then it won't load properly.
"""
pass
def start_call(switchboards, start_area, start_number, end_area, end_number):
pass
def end_call(switchboards, start_area, start_number):
pass
def display(switchboards):
pass
FUNCTIONS:
switch-add [area-code-1]
This will create a new switchboard with the area code specified. The braces are just to indicate that it needs to be replaced with an area code which is a number. If the switchboard exists, you don't create a new one.
switch-connect [area-code-1] [area-code-2]
This connects the switchboard at [area-code-1] with the one at [area-code-2], and also the reverse connection, which means that they are connected to each other. Calls can flow in both directions.
phone-add
phone-add [area-code-1]-[num_part_1]-[num_part_2]
phone-add should add a phone number with the area code specified as well as the phone number with one hyphen between the area code and the phone number, but there can be as many hyphens between any other part of the number. The rest of the number can be combined, or kept as a format with hyphens.
start-call
start-call [phone_number_1] [phone_number_2]
Connecting a call requires a recursive function. It can be a helper function rather than start_call()
start-call should create a connection between the two phone numbers, if the area codes exist, the numbers exist at their proper area codes, and if they are not already in a phone call. It can only be connected if there is a path along switchboards between the two numbers. It is possible that no connection will exist because the two switchboards could not be connected by "trunk lines."
end-call
end-call [phone_number]
end-call should disconnect the two numbers that are connected. The disconnection can occur at either end of the call. If there's no connection from that number, then report that but you don't need to do anything else.
display
The display command should output each switchboard with its area-code. Then output the other area codes/switchboards that it's connected to. Finally output each local phone number and if it is on the hook, or if it's connected to another phone. See the sample output for more on how I think it should generally look to make it readable for the console output.
network-save [filename]
This should save the network in a file. CAN USE CSV OR JSON FILE. You must decide on the file format, which must be able to be saved, and then loaded in a different run of the program. The structure of the network should be saved, but the phone to phone connections can be lost (pretend that all phones are hung up at the start of the load).
network-load [filename]
This should load the file at file-name. When you load a network, you should delete the old network or overwrite it, whichever makes sense for your project.
Output
Enter command: switch-add 443 Enter command: switch-add 410 Enter command: switch-add 656 Enter command: display Switchboard with area code: 443 Trunk lines are: Local phone numbers are: Switchboard with area code: 410 Trunk lines are: Local phone numbers are: Switchboard with area code: 656 Trunk lines are: Local phone numbers are: Enter command: switch-connect 443 410 Enter command: phone-add 656-112-3412 Enter command: phone-add 443-132-1332 Enter command: display Switchboard with area code: 443 Trunk lines are: Trunk line connection to: 410 Local phone numbers are: Phone with number: 1321332 is not in use. Switchboard with area code: 410 Trunk lines are: Trunk line connection to: 443 Local phone numbers are: Switchboard with area code: 656 Trunk lines are: Local phone numbers are: Phone with number: 1123412 is not in use. Enter command: start-call 656-112-3412 443-132-1332 656-112-3412 and 443-132-1332 were not connected. Enter command: switch-connect 656 410 Enter command: start-call 656-112-3412 443-132-1332 656-112-3412 and 443-132-1332 are now connected. Enter command: display Switchboard with area code: 443 Trunk lines are: Trunk line connection to: 410 Local phone numbers are: Phone with number: 1321332 is connected to 656-1123412 Switchboard with area code: 410 Trunk lines are: Trunk line connection to: 443 Trunk line connection to: 656 Local phone numbers are: Switchboard with area code: 656 Trunk lines are: Trunk line connection to: 410 Local phone numbers are: Phone with number: 1123412 is connected to 443-1321332 Enter command: network-save sample1.net Network saved to sample1.net. Enter command: quit |
Step by stepSolved in 4 steps with 5 images
You used forbidden methods. See below. Please update without any of the following in the code.
Forbidden Built-ins/Methods/etc
- break, continue
- methods outside those permitted within allowed types
- for instance str.endswith
- list.index, list.count, etc.
- Keywords you definitely don't need: await, as, assert, async, class, except, finally, global, lambda, nonlocal, raise, try, yield
- The is keyword is forbidden, not because it's necessarily bad, but because it doesn't behave as you might expect (it's not the same as ==).
- built in functions: any, all, breakpoint, callable, classmethod, compile, exec, delattr, divmod, enumerate, filter, map, max, min, isinstance, issubclass, iter, locals, oct, next, memoryview, property, repr, reversed, round, set, setattr, sorted, staticmethod, sum, super, type, vars, zip
- If you have read this section, then you know the secret word is: argumentative.
- exit() or quit()
- If something is not on the allowed list, not on this list, then it is probably forbidden.
- The forbidden list can always be overridden by a particular problem, so if a problem allows something on this list, then it is allowed for that problem.
You used forbidden methods. See below. Please update without any of the following in the code.
Forbidden Built-ins/Methods/etc
- break, continue
- methods outside those permitted within allowed types
- for instance str.endswith
- list.index, list.count, etc.
- Keywords you definitely don't need: await, as, assert, async, class, except, finally, global, lambda, nonlocal, raise, try, yield
- The is keyword is forbidden, not because it's necessarily bad, but because it doesn't behave as you might expect (it's not the same as ==).
- built in functions: any, all, breakpoint, callable, classmethod, compile, exec, delattr, divmod, enumerate, filter, map, max, min, isinstance, issubclass, iter, locals, oct, next, memoryview, property, repr, reversed, round, set, setattr, sorted, staticmethod, sum, super, type, vars, zip
- If you have read this section, then you know the secret word is: argumentative.
- exit() or quit()
- If something is not on the allowed list, not on this list, then it is probably forbidden.
- The forbidden list can always be overridden by a particular problem, so if a problem allows something on this list, then it is allowed for that problem.
- I have the main draw ( picture1). Can you help me draw continue munber 11 to 15?arrow_forwardComputer Science You work as the IT security administrator for a small corporate network. You need to configure the network security appliance. In this lab, your task is to perform the following: Rename the default user account (cisco) with the following parameters: Use the user name NSAAdmin. Use the password KeepOut!@. Set the idle timeout to 15 minutes. Configure this user for LAN access only (no WAN access). Configure the Optional port on the NSA for LAN and configure the LAN ports to act as a DHCP server with the following parameters: Starting IP Address: 198.28.1.100 Ending IP Address: 198.28.1.250 Primary DNS server address: 163.128.78.93 Secondary DNS server address:163.128.80.93 Set the Default Outbound Policy for IPv4 on the firewall to Allow Always and enable all of the available firewall attack checks. Enable the IPS on the LAN interface and set the policy to Detect and Prevent for all categories.arrow_forwardHelp Mearrow_forward
- How does NoSQL data modeling differ from traditional relational data modeling? Provide examples of NoSQL data models.arrow_forwardAs part of the documentation process, a network engineer executes the show cdp neighbour command on several network devices. What does this command want to accomplish?arrow_forwardWhat is the purpose of the listen() function in network programming? Question 9 options: To listen for incoming connections and queue them up for processing by the server To initiate a connection to a remote server To create a socket To accept an incoming connection request and create a new socket for communication with the clientarrow_forward
- q9- Which default mask is used for a Class B network? Select one: A. 255.255.255.0 B. 255.255.255.255 C. 255.0.0.0 D. 255.255.255.252 E. 255.255.0.0arrow_forwardLab – Routing Objective Learn and practice routing using Node and Express. Specification Create a web server that Accepts and processes request messages submitted from browser, and Generates and sends response messages back to browser for display. Your web server must be able to handle URL with hostname and port Request message URL: 0.0.1:3000 Response message: “SUCCESS!” URL with hostname, port and path echo Request message URL: 0.0.1:3000/echo Response message: “SUCCESS! echo” URL with hostname, port, path foxtrot and route parameter value kilo Request message URL: 0.0.1:3000/foxtrot/kilo Response message: “SUCCESS! Received kilo via foxtrot” where the value kilo must be retrieved via the route parameter Invalid/unexpected URL Request message URL: 0.0.1:3000/<any other value> Response message: “FAILED! Fix your URL.” Hostname 127.0.0.1 can be replaced by localhost. Port number 3000 can be replaced by any other port number that is from 1024 (2^11)…arrow_forwardWhy is it suggested that you use the Tcpdump application, and what are the benefits of doing so?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education