class Student:
def __init__(self, i, last, first, ph,
yr):
self.username = i
self.last_name =
last
self.first_name =
first
self.phone = ph
self.year = yr
def update_year(self):
self.year += 1
class OnlineStudent(Student):
"""This class inherits from Student
class"""
def __init__(self, i, last, first, ph, year,
em):
"""Call parent class
constructor"""
Student.__init__(self,
i, last, first, ph, year)
self.email = em
# Initialize empty study
group array
self.study_group =
[]
def __str__(self):
return self.last_name +
"," + self.first_name
def __lt__(self, other):
return self.username
< other.username
def add_group_member(self, member_id):
# Add the member id to
the study group
self.study_group.append(member_id)
--------------------------------------------------------------------------------------------------------------------------------------
Test2.py
import unittest import Student
class OnlineStudentTest(unittest.TestCase): def test_email(self): student = Student.OnlineStudent(1, 'last1', 'first1', 1, 1, "[email protected]") self.assertEqual("[email protected]", student.email, "Email not correct") def test_lt(self): student1 = Student.OnlineStudent(1, 'last1', 'first1', 1, 1, "[email protected]") student2 = Student.OnlineStudent(2, 'last2', 'first2', 1, 1, "[email protected]") self.assertTrue(student1.__lt__(student2), "Student 1 is less than 2") def test_str(self): student1 = Student.OnlineStudent(1, 'last1', 'first1', 1, 1, "[email protected]") self.assertEqual("last1,first1", student1.__str__(), "str function should gives all fields") def test_add_group_member(self): year = 1 student = Student.OnlineStudent(1, 'last1', 'first1', 1, 1, "[email protected]") student.add_group_member("1") self.assertEqual("1", student.study_group[0], "Group member should be added")
this is written in python Goal: Implement and test the Onlinestudent class as shown in the Student/OnlineStudent UML Dia...
python programming Goal: Implement and test the OnlineStudent class as shown in the Student/OnlineStudent UML Diagram. Input Files: students.txt study-groups.txt The study_group instance variable is a list that contains the username values of the other members in the student's study group. Details: Implement the OnlineStudent class in the module onlinestudent.py as specified by the Student/OnlineStudent UML Diagram. OnlineStudent is the derived class of the base classStudent. The __lt__ method for an OnlineStudent object should return true if self.username < other.username...
in python please I need both unittest and traditional test Goal: Implement and test the OnlineStudent class as shown in the Student/OnlineStudent UML Diagram. Input Files: students.txt study-groups.txt The study_group instance variable is a list that contains the username values of the other members in the student's study group. Details: Implement the OnlineStudent class in the module onlinestudent.py as specified by the Student/OnlineStudent UML Diagram. OnlineStudent is the derived class of the base classStudent. The __lt__ method for an OnlineStudent...
PRBE Errors in Python Class and Test Filles. Correct the errors in source code in the O1ympicMeda traditional and unit rt c. Correct class and in the modules olympicmedal. code- do not recopy (5 Py, testi.py, and teat2.py. Mark your corrections directly on the source point penalty for recopying). Adding, deleting, or correcting a pair of parentheses braces ( { }), single quotes (·. double quotes (- .), or triple quotesぃ.. test scripts on pages 6 and 7. There are...
PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...
Last picture is the tester program! In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...
Objectives You will implement and test a class called MyString. Each MyString object keeps track of a sequence of characters, similar to the standard C++ string class but with fewer operations. The objectives of this programming assignment are as follows. Ensure that you can write a class that uses dynamic memory to store a sequence whose length is unspecified. (Keep in mind that if you were actually writing a program that needs a string, you would use the C++ standard...