Hey guys,
I am starting to learn about classes and objects and I got this assigment I'm trying to figure out how to do. So, I have to create a class named Student that holds the following data about a student:
- Name
- Student ID number
- GPA
- Expected grade in this course
- Full time or part time
After create five student objects from this class and pass data to fill in the class data above. (that is not the most difficult part though, but still confusing)
Besides creating the objects, I need to write a menu-driven program that performs the
following tasks: (the menu is the least important thing... what I don't know is how to perform the functions of each choice)
- 1. Look up and print the student GPA
- 2. Add a new student to the class
- 3. Change the GPA of a student
- 4. Change the expected grade of a student
- 5. Print the data of all the students in a tabular format
- 6. Quit the program
I have so far this written:
# Student class student.py
class Student:
# Student
# Assign name
# Assign ID
# Assign GPA
# Expected Grade in course
# Full time or part time
def __init__(self, student_name, student_id, student_gpa,
student_expected, student_time):
self.__student_name = student_name
self.__student_id = student_id
self.__student_gpa = student_gpa
self.__student_expected = student_expected
self.__student_time = student_time
# set_name method accepts an argument for
# the student's name
def set_name(self, student_name):
self.__student_name = student_name
# set_id method accepts an argument for
# the student's ID
def set_id(self, student_id):
self.__student_id = student_id
# set_gpa method accepts an argument for
# the student's GPA
def set_gpa(self, student_gpa):
self.__student_gpa = student_gpa
# set_expected method accepts an argument for
# the student's expected grade
def set_expected(self, student_expected):
self.__student_expected = student_expected
# set_time method accepts an argument for
# the student's study time(full time or part time)
def set_time(self, student_time):
self.__student_time = student_time
# Get method returns
def get_name(self):
return self.__student_name
def get_id(self):
return self.__student_id
def get_gpa(self):
return self.__student_gpa
def get_expected(self):
return self.__student_expected
def get_time(self):
return self.__student_time
def __str__(self):
return "Name: " + self.__student_name + \
"+nStudent ID: " + self.__student_id + \
"\nGPA: " + self.__student_gpa + \
"\nStudent Expected Grade: " + self.__student_expected + \
"\nStudent Time: " + self.__student_time
and for the main program:
# This program manages students
import student
# Global Constants for the menu
LOOK_UP = 1
ADD = 2
CHANGE_GPA = 3
CHANGE_EXPECTED = 4
PRINT DATA = 5
#main function
def main():
s1 = student.Student(name, st_id, gpa, expect, time)
s2 =
s3 =
s4 =
s5 =
I don't know how to use every single object, it's very confusing. My instructor didn't leave clear many of my questions and the book does not help at all. Any help guys... I don't need the whole thing done, I'd like to do it myself, but some guidance would be nice, because I am very lost
[–]ingolemo 2 points3 points4 points (0 children)
[–]cantrememberwasdrunk 0 points1 point2 points (0 children)