Question: Goal: Implement and test the Student class as shown in the Student/OnlineStudent UML Diagram. Relevant Examples: Person Pet The Card class from Project 3. Details:

- Goal: Implement and test the Student class as shown in the Student/OnlineStudent UML Diagram.
- Relevant Examples: Person Pet The Card class from Project 3.
- Details:
- Implement the Student class in the module student.py as specified by the Student/OnlineStudent UML Diagram.
- Write the traditional test script test1.py and unit test script test2.py that test all of the instance variables and methods in the Student class. Test these instance members in this suggested order:
__init__ __str__ __repr__ username first_name last_name phone year update_year
- Reminder: test the __init__ method by calling the constructor, which creates a Student object:
s = Student("1111", "Carter", "Marilyn", "312/473-4837", 1) - The __init__ method should validate the year. If the input parameter yr is less than 1, set the instance variable year to 1; if yr > 4, set self.year to 4; if 1
- The update_year method updates the year, but only if the year is less than 4: if year
- Test the __str__ method by calling the standalone str method. If s is a Student object,
print(str(s))
orprint(s)
(str is automatically called when s is printed). - Test the __repr__ method by calling the standalone repr method like you did for the str method.
- To test the instance variables, just print each of their values, for example:
print(s.username)
- Convert your traditional test script test1.py into a unit test script test2.py.
- Remember that the str method must be called explicity when testing it, for example:
self.assertEqual(str(s), \ "1111 Carter Marilyn 312/473-4837 1")
Student +username int +last_name: str +first_name str +phone str + year: int _init_(self: Student, i: int, last: str, first: str, ph:str, yr: int) _str_(self: Student) _repr__(self: Student) +update_year(self Student) Online Student +email:str + study_group: strl] -init-(self: OnlineStudent, i : int, lapt : str, first: str. ph : str, yr : int, em : str) -_str_(self: OnlineStudent) _repr__(self: OnlineStudent) lt-(self. OnlineStudent, other. OnlineStudent) + add group member self: OnlineStudent, member id: int)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
