#Akshat shah
#IT 212

class Student:
    # __init__ method is called whenever a new Person 
    # object is created.
    def __init__(self, the_username, the_first_name, the_last_name, the_phone, the_year):
        self.first_name = the_first_name
        self.last_name = the_last_name
        self.phone = the_phone
        self.year = the_year
        self.username = the_username

        if the_year > 4:
            self.year = 4
        if 1 <= the_year and the_year<= 4:
            self.year = the_year
            
    #Method for updating the year
    def update_year(self):
        if self.year < 4:
            self.year += 1

    # Define return value for str method.
    def __str__(self):
        return f"{self.username} {self.first_name} {self.last_name} {self.phone} {self.year}"

    #Define return value for repr method.
    def __repr__(self):
        return str(self)
        
        
***************************
**********test1.py*********
***************************


#Importing the student class from the student file
from student import Student

#Test the init method
s = Student("1111", "Carter", "Marilyn", "312/473-4837", 1)
print(s.username,s.first_name, s.last_name, s.phone, s.year)

#Test the string method
print(str(s))

#Test the year
print(s.year)

#Test the update_year method
s.update_year()
print(s.year)

#Test the Repr method
print(repr(s))

#Test the username 
print(s.username)

#Test the firstname
print(s.first_name)

#Test the lastname
print(s.last_name)

#Test the phone
print(s.phone)


***************************
**********test2.py*********
***************************


from student import Student

import unittest

class MyUnitTestClass(unittest.TestCase):

    def test_1(self):
        s = Student("1111", "Carter", "Marilyn", "312/473-4837", 1)
        
        #Test the string method
        self.assertEqual(str(s),"1111 Carter Marilyn 312/473-4837 1")

        #Test the Repr method
        self.assertEqual(repr(s), '1111 Carter Marilyn 312/473-4837 1')

        #Test the username 
        self.assertEqual(s.username,"1111")

        #Test the firstname 
        self.assertEqual(s.first_name,"Carter")

        #Test the lastname
        self.assertEqual(s.last_name,"Marilyn")

        #Test the phone
        self.assertEqual(s.phone,"312/473-4837")

        #Test the year
        self.assertEqual(s.year,1)

        #Test the update year method
        c = s.update_year()
        self.assertEqual(s.year,2)

if __name__ == "__main__":
    unittest.main()