QuestionQuestion

Transcribed TextTranscribed Text

Student Class List Project 3 Purpose: To better understand Linked lists Recursion Unit Tests You will write an application which stores the courses taken by student and prints outa report Data will be read from data-txt file Once all data has been read from the data-txt file, your program should print report as shown in the Program Output section below. After the list of coll ses has been printed, you should ther calculato and display the cumulative GPA of all courses in the list. Important Constraints 1. You must implement a linked list as the underlying data structure 2. Course entrics will be stored in the linked list structure. 3. All operations and list traversals MUST use recursioni Loops are NOT allowed in your linked list implementation. (Loops can be used in the code with reads the data from the data-txt file. but NOT in any other modules) 4. Each class will be in separate module (i.c. coursc.py, courselist py) and the driver program which reads the data from the data-t= file will be in main.py 5. Toallow the UnitTest to test for recursion usage, you MUST add the following to each module which has recursive functions: from recurs .oncounter import RecursionCounten and at the beginining of EVERY recursive function youmust add this line Recurs sionCounter( Course ADT (course.py) You will implement Course ADT which implements the following methods constructori must have default values for all parameters and must validate all parameters number() retrieve Course Number asan integer name(iretrieve Course Name asa string credit_he() retrieve Creditsas a floating-point number grade() retrieve Grade as a numerio value in range -0.0 _st 0 returns string representing single Course asshown in the Program Output section The by the student will be provided ina data file- You will have to parse the data from that file and storeit ina Linked List of courses CourseList ADT (courselist.py) Your CourseList ADT must usea Linked List implementation. The courso list must be able to hold an unlimited number of Courses- The CourseList ADT implements the following methods constructor to initialize all needed data for an emptylist insert(Coursc): insert the specified Course in Course Number ascending order remove(number) remove the first occurrence of the specified Courso remove all(number) removes ALL occurrences of the specified Course find(number) find the first occurrance of the specified course in the list or return -1 size() return the number of itemsin thelist calculate_ gpaC return the GPA using all courses in thelist is_sorted() return True ifthe listis sorted by Course Number, False otherwise _st=_ returnsa string with cach Course' data on separate line (as shown in the Program Output) _iter __next__ the linked list must be iterable Program Output - "Users\Dana Doggett OneDr ive \Documents\UMU\Spring 2029\cs2429\Projects \Project 2>python mai urrent ist: (5) s1030 introduction to Computers Grade:3 2 Credit Hours: 2.0 1480 Introduction to Progi ramming Grade:3.6 Credit Hours 4.0 s1410 C++ Programming Grade: 2.6 Credit Hours 4.0 s2420 Introduction to Data Structures Grade: 3.2 Credit Hours: 4.6 52810 Computer Architecture Grade 3.8 Credit Hours 3.0 Cumulative GPA: 3.259 \Users Dana Doggett\OneDr ive \Dacuments\Unu\Spring 2020\cs2420\Projects\Project 2> Figure 1. Example Program Output Test Cases Your three files (main.py course py, and courselist- py) will be auto-tested with the supplied test_main.py Alc- This is standard Python UnitTest filcand will exercise your code to ensure itis working properly. If you fallany test, you should be able to find th problem keep working on it untilall tests pass- Use this UnitTest as development toolto polish yollt programining skills Your grado will be based on both the results of the UnitTestsand proper program output (see above) (the output of main() will also be evaluated by unittest.) In addition to fully exercising your code, the UnitTest will also use PyLint to check your "code quality" It usesa standard Python coding standard called Pcp-8 It may seetn tedious at first, but you can integrate PyLint into most IDE' and this will help you create more readable quality code- ALMOST ALL COMPANIES USE SOME SORT OF CODING STANDARD, so get used to nowl All python files must pass Py Lint with a score of8 or better. Grading (100 points) All scoresare aresultof the Unit Test Empty Course 5 Nominal Course 5 Empty Course List 5 Nominal Course List 35 Recursion 20 Coding Standards 15 main()output 15 Files to turn in through Canvas main.py (driver file) course.py courselist.py

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

from recursioncounter import RecursionCounter


"""
CourseList class implements
linked list data structure to store course object.
"""
class CourseList:
    def __init__(self):
       """
       CourseList constructor
       """
       self.head = None
       self.__tmp = None

    def insert(self, course):
       """
       This method inserts new course in the list
       :param course: the course to be inserted
       :return: None
       """
       self.head = self.insert_helper(self.head, None, course)

    def insert_helper(self, node, prev_node, course):
       """
       Helper method to insert new course in the list.
       :param node: the current node of the list.
       :param prev_node: the previously traversed node
       :param course: the course to be inserted.
       :return: the inserted node.
       """
       RecursionCounter()
       if node is None:
            return course
       if node.number() > course.number():
            if prev_node is not None:
                course.next = node
                prev_node.next = course
                return course
            else:
                course.next = node
                self.head = course
                return course
       node.next = self.insert_helper(node.next, node, course)
       return node

    def remove(self, number):
       """
       Removes the first occurrence of the specified Course.
       :param number: the number to be removed.
       :return: None
       """
       self.remove_helper(self.head, None, number)

    def remove_helper(self, node, prev_node, number):
       """
       Removes the first occurrence of the specified Course.
       :param node: the currently traversed node.
       :param prev_node: the previously traversed node.
       :param number: the number to be removed.
       :return: None
       """
       RecursionCounter()
       if node is None:
            return
       elif node.number() == number:
            if prev_node is not None:
                prev_node.next = node.next
            else:
                self.head = node.next
            del node
       else:
            self.remove_helper(node.next, node, number)

    def remove_all(self, number):
       """
       Removes all occurrence of the specified Course.
       :param number: the number to be removed.
       :return: None
       """
       self.remove_all_helper(self.head, None, number)

    def remove_all_helper(self, node, prev_node, number):
       """
       Removes all occurrence of the specified Course.
       :param node: the currently traversed node.
       :param prev_node: the previously traversed node.
       :param number: the number to be removed.
       :return: None
       """
       RecursionCounter()
       if node is None:
            return
       elif node.number() == number:
            if prev_node is not None:
                prev_node.next = node.next
                self.remove_all_helper(node.next, prev_node, number)
            else:
                self.head = node.next
                self.remove_all_helper(node.next, self.head, number)
            del node
       else:
            self.remove_all_helper(node.next, node, number)

    def find(self, number):
       """
       Finds the course having the same given number.
       :param number: the number to be searched.
       :return: the course if found otherwise returns -1
       """
       return self.find_helper(self.head, number)

    def find_helper(self, node, number):
       """...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$20.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats