Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started