Question: NOTE: Use pycharm Instructions: Modify this program for the question below: # class for DNS class DNS: # constructor method def __init__(self): self.__dict = {}
NOTE: Use pycharm
Instructions:
Modify this program for the question below:
# class for DNS class DNS: # constructor method def __init__(self): self.__dict = {} # create a private instance variable (a empty dict) # your keys are going to be hashable # and dictionaries possess O(1) average complexity. # method to update DNS with new domain name def add(self, name, IPA): if name not in self.__dict.keys(): # if domain name already not in dict self.__dict[name] = IPA # than add it to dict else: # else print this message to screen print("Domain name already exist in DNS database") # lookup method def lookup(self, name): # domain name as argument if name in self.__dict.keys(): # if domain name in dict than return self.__dict[name] # return IPA for domain name else: # else return None return None 
Problem: An Internet Service Provider (ISP) must, as part of its service to customers, provide a Domain Name Server (DNS). A DNS is a server that maintains a database of domain names, such as www.griffith.edu.au, and their corresponding Internet Protocol Addresses (IPA), such as 132.234.243.22. A domain name has only one IPA, but an IPA may have many domain names. Define a class that simulates a DNS. It must have: . a method for updating the DNS with a new domain name and its IPA; a method for returning the IPA for a domain name, or None if it does not exist; and whatever private attributes are required to support the methods. Write a test program that allows the user to test the class, by typing in fake domain names and IPAs to update the DNS, and domain names to look up. An example of the output from the test program is like this: ? u www.google.com 8.8.8.8 ? u www.amazon.com 2.2.2.2 ? u www.cnn.com Bad command. ? I www.google.com 8.8.8.8 ? I www.amazon.com 2.2.2.2 ? I www.cnn.com None ? where: a u DNS IPA updates the DNS with a new domain name and its IPA; I DNS returns the IPA for a domain name, or None if it does not exist; and q ends the test program. Bad inputs are to be reported and ignored
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
