Question

In: Computer Science

''' File: pyPatientLL.py Author: JD ''' class Node: #ADT        def __init__(self, p = None):             ...

'''

File: pyPatientLL.py

Author: JD

'''

class Node: #ADT

       def __init__(self, p = None):

             self.name = ""

             self.ss = self.age = int(0)

             self.smoker = self.HBP = self.HFD = self.points = int(0)

             self.link = None

             #if list not empty

             if p != None:

                    p.link = self

      

ptrFront = ptrEnd = None

choice = int(0)

def menu():

       print( "\n\tLL Health Clinic\n\n")

       print( "1. New patient\n")

       print( "2. View patient by SS#\n")

       print( "3. Update patient's record\n")

       print( "4. Quit the App\n\n")

       print( "Enter your choice: ")

def getChoice():

       choice = int(input(""))

       # Validate the menu selection

       while ((choice < 1) or (choice > 4)):

             print( "Please enter 1, 2, 3, or 4: ")

             choice = int(input(""))

       return choice

def getInfo(ptr):                            #Populate the record

       ptr.name = input("Enter patient's name: ")

       ptr.age = int(input("Enter age: "))

       ptr.ss = int (input("Enter patient's SS: "))

       habits = input("Enter habits 1/0: smoker, HBP, HFD:").split()

       ptr.smoker, ptr.HBP, ptr.HFD = map(int, habits)

       calPoints(ptr)

# implement flowchart here

def calPoints(ptr):

       pass

def searchBySS(ptr, ssKey):     #search by SS

       pass

def dispPatient(ptr):                  #disp record

       pass

def updatepatinet(ptr):                #update any habits (smoking, HBP, HFD)

       pass                                                #recalculate points

def processChoice(choice):

       ptr = None

       global ptrEnd

       global ptrFront

       # Procee based on user input

      

       if choice == 1:    #New patinet

             if (ptrEnd == None):

                    ptrEnd = ptrFront = Node(ptrEnd)

             else:

                    ptrEnd = Node(ptrEnd)

                   

             getInfo(ptrEnd)    #Populate the record

       elif choice == 2: #case 2 find patient

             key = int(input("Enter SS: "))

             if (ptr == searchBySS(ptrFront, key)):

                        dispPatient(ptr)

             else:

                          print ("\nRecord not found\n\n")

       elif choice == 3:         #case 3 update patient

             key = int(input("Enter SS: "))

             if (ptr == searchBySS(ptrFront, key)):

                          updatepatinet(ptr)

             else:

                          cout<<"\nRecord not found\n\n";

      

def main():

       do = bool(True)

       while(do == True):

             menu()

             choice = getChoice()

             if choice == 4:

                    do = False

             else:

                    processChoice(choice)

#call main

main()

KEEP THE PYTHON CODE AS IT IS and try the python singly linked list code first and ask questions.

Secondly implement the functions having just "pass" one at a time and fully test and move on to next function.

"calPoints function" is implemented based on the flowchart you will find in the announcement section.

Solutions

Expert Solution


Related Solutions

For python... class car:    def __init__(self)          self.tire          self.gas    def truck(self,color)        &nb
For python... class car:    def __init__(self)          self.tire          self.gas    def truck(self,color)               style = color                return    def plane(self,oil)              liquid = self.oil + self.truck(color) For the plane method, I am getting an error that the class does not define __add__ inside init so I cannot use the + operator. How do I go about this.             
1) What is the argument in “class AddressBook(object):” 2) What is the roll of “def __init__(self):”?...
1) What is the argument in “class AddressBook(object):” 2) What is the roll of “def __init__(self):”? 3) What is the roll of “def __repr__ (self):”? 4) Please copy and run “Addressbook” Python program. Submit the code and the output 5) Discuss the two outputs’ differences (data type). 6) Please add 2 more people and report the output. Code: class AddressBook(object): def init_(self): self.people=[] def add_entry(self, new_entry): self.people.append(new_entry) class AddressEntry(object): def __init__(self, first_name=None, family_name= None, email_address= None, DOB= None): self.first_name =...
write pseudocode for this program . thank you import random class cal():    def __init__(self, a,...
write pseudocode for this program . thank you import random class cal():    def __init__(self, a, b):        self.a = a        self.b = b    def add(self):        return self.a + self.b    def mul(self):        return self.a * self.b    def div(self):        return self.a / self.b    def sub(self):        return self.a - self.b def playQuiz():    print("0. Exit")    print("1. Add")    print("2. Subtraction")    print("3. Multiplication")    print("4. Division")...
"""stack.py implements stack with a list""" class Stack(object): def __init__(self): #creates an empty stack. O(1) self.top...
"""stack.py implements stack with a list""" class Stack(object): def __init__(self): #creates an empty stack. O(1) self.top = -1 #the index of the top element of the stack. -1: empty stack self.data = [] def push(self, item): # add item to the top of the stack. O(1) self.top += 1 self.data.append(item) def pop(self): # removes and returns the item at the top O(1) self.top -=1 return self.data.pop() def peek(self): # returns the item at the top O(1) return self.data[len(self.data)-1] def isEmpty(self):...
How would I setup this dictionary for Python 3? class Student(object): def __init__(self, id, firstName, lastName,...
How would I setup this dictionary for Python 3? class Student(object): def __init__(self, id, firstName, lastName, courses = None): The “id”, “firstName” and “lastName” parameters are to be directly assigned to member variables (ie: self.id = id) The “courses” parameter is handled differently. If it is None, assign dict() to self.courses, otherwise assign courses directly to the member variable. Note: The “courses” dictionary contains key/value pairs where the key is a string that is the course number (like “course1”) and...
Run the  Python Queue Line Simulator  three times Python Queue Line """ File: pyQueueSim.py Author: JD """ import...
Run the  Python Queue Line Simulator  three times Python Queue Line """ File: pyQueueSim.py Author: JD """ import random print("Queue as a customer line\n") queue = []              # Empty que y = int(0) # Queue up some customers for i in range(1,20):     x = random.randint(1, 20)     if x >= 2 and x<= 8:       queue.append(x)      # Add to the front        # Simulate cumstomer line processing while True:    x = random.randint(1, 20)    if x >= 2 and x<= 8:       queue.append(x *2)      # Add to the front...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def g(self): return 2 class C2(C1): def f(self): return 3*self.g() class C3(C1): def g(self): return 5 class C4(C3): def f(self): return 7*self.g() obj1 = C1() obj2 = C2() obj3 = C3() obj4 = C4() For this problem you are to consider which methods are called when the f method is called. Because the classes form part of an inheritance hierarchy, working out what happens will...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def...
Inheritance - Method Calls Consider the following class definitions. class C1(): def f(self): return 2*self.g() def g(self): return 2 class C2(C1): def f(self): return 3*self.g() class C3(C1): def g(self): return 5 class C4(C3): def f(self): return 7*self.g() obj1 = C1() obj2 = C2() obj3 = C3() obj4 = C4() For this problem you are to consider which methods are called when the f method is called. Because the classes form part of an inheritance hierarchy, working out what happens will...
Class AssignmentResult An object that represents the result of an assignment. __init__(self, id:int, assignment: Assignment, grade:...
Class AssignmentResult An object that represents the result of an assignment. __init__(self, id:int, assignment: Assignment, grade: float): """ This will contain the ID of the student, the assignment that the student worked on and the grade the student received on the assignment. :param id: The ID of the student that created this Assignment result :param assignment: The Assignment that the student worked on. :param grade: A number between 0-1 representing the numerical grade the student received """ id(self) -> int:...
please complete the header file that contains a class template for ADT Queue and complete all...
please complete the header file that contains a class template for ADT Queue and complete all the member functions in the class template. Submit the header file only, but please write a source file that tests all the member functions to make sure they are working correctly. queue.h #ifndef _QUEUE #define _QUEUE #include"Node.h" template<class ItemType> class Queue { private:    Node<ItemType> *backPtr;    Node<ItemType> *frontPtr; public:    Queue(); //Default constructor    Queue(const Queue<ItemType> &aQueue);    bool isEmpty() const;    bool...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT