Dies ist die wichtigste Datei des Codes:Konzept der OOP in Python
#for student registration in a college
from la_class import *
from la_class0 import *
from la_class1 import *
student1_name = Student(name1)
student1_pref = Branch(pref)
print("Student1 details : ",student1_name.name)
print("Student1 branch : ",student1_pref.preference)
student1_course = Course(core,el1,el2)
print("core course---",student1_course.core)
print("elective course---1.",student1_course.elective1)
print("elective course---2.",student1_course.elective2)
la_class Datei:
#takes the student name input
class Student:
def __init__(self,name):
self.name = name
print("___student details___ ")
name1 = raw_input("name1 > ")
la_class0 Datei:
#this contains the preference operations
class Branch:
def __init__(self,pref):
self.preference = pref
print("__________")
print("(1.) __CSE__")
print("(2.) __CCE__")
print("(3.) __ECE__")
print("(4.) __MME__")
usr = raw_input("_choose the above preferences_ ")
if usr is "1":
pref = "CSE"
elif usr is "2":
pref = "CCE"
elif usr is "3":
pref = "ECE"
else:
pref = "MME"
la_class1 Datei:
#takes the input for courses
class Course():
def __init__(self,core,elec1,elec2):
self.core = core
self.elective1 = elec1
self.elective2 = elec2
print("___course-details___")
#core courses ---
print("--available-core-courses--")
print("(1.) __OOP__")
print("(2.) __COA__")
print("(3.) __SSC__")
co = raw_input("Choose any above course")
if co is "1":
core = "OOP"
elif co is "2":
core = "COA"
else:
core = "SSC"
#Elective courses ---
print("Choose two elective courses")
print("(1.) __PTSP__","(2.) __YOGA__","(3.) __POC__")
el1 = raw_input("elective 1 : ")
el2 = raw_input("elective 2 : ")
Hier funktioniert der Code nur für ein Studentenobjekt, d. H. student1, wie den Code zu implementieren, so dass der Benutzer so viele Studentenregistrierung haben kann, wie er will (es sollte objektorientiert sein)?
Es ist mir ein wenig unklar ist, was Sie willst du machen? Sie möchten ein Schülerobjekt konstruieren, das alle Namen trägt? –
wie in c können wir Array-Eingabe nehmen (self, name [10], pref [10]) .Dieser Weg in Python – BoRRis