python programming
self.username < other.username
__init__ __str__ __repr__ __lt__ email study_group add_group_member__init__, __str__, and __repr__ are tested again in the OnlineStudent class because they are overridden methods.
students.txt
mcarter,Carter,Marilyn,312/473-4837,1,[email protected] ggraber,Graber,Gary,312/837-2837,3,[email protected] ccarpent,Carpenter,Carrie,312/377-2873,2,[email protected] ccheng,Cheng,Sam,312/272-4473,1,[email protected] obooker,Booker,Olivia,312/928-3980,4,[email protected] rscanchez,Sanchez,Ricardo,312/838-9928,2,[email protected] cdharan,Dharan,Connor,312/263-3922,2,[email protected] yboulet,Boulet,Yvette,312/235-3728,3,[email protected] rbolger,Bolger,Raymond,312/663-3827,4,[email protected] sstrickl,Strickland,Sheryl,312/878-9800,1,[email protected]
study-groups.txt
ccarpent,yboulet,obooker yboulet,ccarpent,obooker obooker,ccarpent,yboulet ccheng,cdharan,rbolger,ggraber cdharan,rbolger,ggraber,ccheng rbolger,ggraber,ccheng,cdharan ggraber,ccheng,cdharan,rbolger mcarter,sstrickl sstrickl,mcarter
CODE:(TESTING STUDENT CLASS)
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 __str__(self): return "Username: "+self.username+"\nName: "+self.first_name+" "+self.last_name+"\nPhone: "+self.phone+"\nYear: "+str(self.year) def __repr__(self): return f'Student("{self.username}", "{self.last_name}","{self.first_name}","{self.phone}",{self.year})' def update_year(self): self.year = int(input("Enter new value for year")) def main(): l = [] fh = open('students.txt','r') for line in fh.readlines(): i,last,first,ph,yr,mail = line.split(',') l.append(Student(i,last,first,ph,int(yr))) fh.close() for i in l: print(i) main()
OUTPUT:
CODE:(TESTING ONLINESTUDENT CLASS)
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 __str__(self):
return "Username: "+self.username+"\nName: "+self.first_name+"
"+self.last_name+"\nPhone: "+self.phone+"\nYear:
"+str(self.year)
def __repr__(self):
return f'Student("{self.username}",
"{self.last_name}","{self.first_name}","{self.phone}",{self.year})'
def update_year(self):
self.year = int(input("Enter new value for year"))
class OnlineStudent(Student):
def __init__(self,i,last,first,ph,yr,em):
super().__init__(i,last,first,ph,yr)
self.email = em
self.study_group = []
def __str__(self):
return super().__str__()+"\nEmail: "+self.email+"\nStudy group:
"+self.study_group
def __lt__(self,other):
if self.username<other.username:
return True
else:
return False
def add_group_member(self,member_id):
self.study_group.append(member_id)
python programming Goal: Implement and test the OnlineStudent class as shown in the Student/OnlineStudent UML Diagram....
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...
this is written in python Goal: Implement and test the Onlinestudent class as shown in the Student/OnlineStudent UML Diagram Relevant Examples: EmployeeHierarchy PersonArray Pet 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: 1. 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 class student. 2. The_1t__method for an...
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...