Question: Write a Student class that stores information for a student. The class should include the following instance variables: o id , an integer identifier for

Write a Student class that stores information for a student. The class should include the following instance variables:

oid, an integer identifier for the student

olastName, a string for the student's last name

ocredits, an integer representing the number of course-credits the student has earned

ocourseLoad, an integer representing the current number of credits in progress

Write the following methods for your Student class:

oA constructor (__init__) that, given an id, and a name, creates a Student with those values and no course-credits and no course load.

oA registerCurrent method that sets the current course load. The course load must be positive and no greater than 4 credits, otherwise no change happens

oA withdraw method, which decreases the course load by one credit, but never goes below 0.

oA passedCourse method, which removes one course from the current course load and adds to the students overall course-credits.

oA createEmail method, which returns a string. The string should be an email address of the student's name combined with their ID and remainder of @school.edu. For example, a student with last name "Jone", and ID 31 should return "jone31@school.edu"

This is the code so far

class Student: def __init__(self, i_d, lastName): self.i_d = i_d self.lastName = lastName self.courseLoad = 0 self.credits = 0 self.email = ''

def registerCurrent(self, courseLoad): if courseLoad 4: self.courseLoad = 0;

else: self.courseload = courseLoad return self.courseLoad

def withdraw(self): if self.courseLoad > 0: self.courseLoad = self.courseLoad -1

else: self.courseLoad = 0 return self.courseLoad

def passedCourse(self): if self.courseLoad > 0: self.courseLoad = self.courseLoad - 1 self.credits = self.credits + 1 return self.credits

def createEmail(self): self.email = self.lastName + str(self.i_d)+ '@school.edu' return self.email

student = Student(31, "Jone") print(student.registerCurrent(4)) print(student.withdraw()) print(student.passedCourse()) print(student.createEmail())

The print statement returns

Write a Student class that stores information for a student. The class

Jone31@school.edu

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!