0% found this document useful (0 votes)
21 views

Programming Project

The document defines Person, Doctor, and Student classes with attributes and methods. It also contains doctor_system and student_system functions to create accounts and allow interactions like viewing/changing details.

Uploaded by

4brc4jywtm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Programming Project

The document defines Person, Doctor, and Student classes with attributes and methods. It also contains doctor_system and student_system functions to create accounts and allow interactions like viewing/changing details.

Uploaded by

4brc4jywtm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

class Person:

def __init__(self, name, NationalID, phone,


program,faculty,semester,year):
self.name = name
self.__NID = NationalID
self.phone = phone
self.program = program
self.faculty = faculty
self.semester = semester
self.year = year

def print_account_details(self):
print("Account Details:")
print("Name:", self.name)
print("NationalID:", self.__NID)
print("Phone:", self.phone)
print("Faculty:", self.faculty)
print("Program:", self.program)
print("Semester:", self.semester)
print("Year:", self.year)

class Doctor(Person):
def __init__(self, name, NationalID, phone, program,
faculty,semester,year, doctor_code, course, salary):
super().__init__(name, NationalID, phone, program,
faculty,semester,year)
self.doctor_code = doctor_code
self.course = course
self.salary = salary
self.hours_worked = 0

def print_account_details(self):
super().print_account_details()
print("Doctor Code:", self.doctor_code)
print("Course:", self.course)
print("Salary:", self.salary)
print("Hours Worked:", self.hours_worked)

def check_course(self):
print("Course:", self.course)

def change_course(self, new_course):


self.course = new_course
print("Course changed to:", self.course)

def check_hours_worked(self):
print("Hours Worked:", self.hours_worked)

def check_salary(self):
if self.hours_worked > 30:
overtime = self.hours_worked - 30
overtime_amount = overtime * (self.salary / 30)
total_salary = self.salary + overtime_amount
print("Salary (including overtime):", total_salary)
else:
print("Salary:", self.salary)

def add_hours_worked(self, hours):


self.hours_worked += hours
print("Hours Worked added. Total hours worked:",
self.hours_worked)

def doctor_system():
print("Welcome to the Doctor System!")

name = input("Enter your name: ")


NationalID = input("Enter your NationalID: ")
phone = input("Enter your phone number: ")
program = input("Enter your program: ")
faculty =input("Enter your Faculty: ")
semester = input("Enter your semester: ")
year = input("Enter your year: ")
doctor_code = input("Enter your doctor code: ")
course = input("Enter your course: ")
salary = float(input("Enter your salary: "))

doctor = Doctor(name, NationalID, phone, program,


faculty,semester,year, doctor_code, course, salary)
print("Account created successfully!")

while True:
print("\nWelcome Doctor " + name +", What do you need
to do:")
print("1. Doctor Account Details")
print("2. Check Course")
print("3. Change Course")
print("4. Check Hours Worked")
print("5. Check Salary")
print("6. Add Hours Worked")
print("7. Logout and Exit")

choice = input("Enter your choice (1-7): ")

if choice == "1":
doctor.print_account_details()
elif choice == "2":
doctor.check_course()
elif choice == "3":
new_course = input("Enter the new course: ")
doctor.change_course(new_course)
elif choice == "4":
doctor.check_hours_worked()
elif choice == "5":
doctor.check_salary()
elif choice == "6":
hours = float(input("Enter the number of hours to
add: "))
doctor.add_hours_worked(hours)
elif choice == "7":
print("Logged out. Exiting Doctor System.")
break
else:
print("Invalid choice. Please try again.")

class Student(Person):
def __init__(self, name, NationalID, phone, program,
faculty,semester,year, student_id, university_email):
super().__init__(name, NationalID, phone, program,
faculty,semester,year)
self.student_id = student_id
self.university_email = university_email

def print_account_details(self):
super().print_account_details()
print("Student ID:", self.student_id)
print("University Email:", self.university_email)

def check_NID(self):
print("National ID:", self._Person__NID)

def change_NID(self, new_NID):


self._Person__NID = new_NID
print("National ID changed to:", self._Person__NID)

def student_system():
print("Welcome to the Student System!")

# Account creation
name = input("Enter your name: ")
NationalID = input("Enter your National ID: ")
phone = input("Enter your phone number: ")
program = input("Enter your program: ")
faculty =input("Enter your Faculty: ")
semester = input("Enter your semester: ")
year = input("Enter your year: ")
student_id = input("Enter your student ID: ")
university_email = input("Enter your university email: ")

student = Student(name, NationalID, phone,


program,faculty,semester,year, student_id, university_email)
print("Account created successfully!")

while True:
print("\nWelcome " + name +", What Do you need to do:")
print("1. Student Account Details")
print("2. Check National ID")
print("3. Change National ID")
print("4. Logout and Exit")

choice = input("Enter your choice (1-4): ")

if choice == "1":
student.print_account_details()
elif choice == "2":
student.check_NID()
elif choice == "3":
new_NID = input("Enter the new National ID: ")
student.change_NID(new_NID)
elif choice == "4":
print("Logged out. Exiting Student System.")
break
else:
print("Invalid choice. Please try again.")

person = Person("Mariam", "1234567890", "123-456-7890",


"Business", "BIS", "Fall", 2023)

doctor = Doctor("Dr. Mohamed Attia", "0987654321",


"123-321-4567", "Business", "Programming", "Spring", 2023,
"DOC123", "Human Anatomy", 5000)

student = Student("Mariam", "2345678912", "123-111-1234",


"BIS", "Programming", "Fall", 2022,
"2122919", "mariam@university.edu")

def login_menu():
print("Login Menu:")
print("1. Doctor System")
print("2. Student System")
choice = input("Enter your choice (1 or 2): ")
return choice

# Main program
choice = login_menu()

if choice == "1":
doctor_system()

elif choice == "2":


student_system()

else:
print("Invalid choice. Please try again.")

You might also like