PDFPrintE-mail

Object Oriented Code Description

Back
The description of an object oriented code snippet example:

This is an object model for a courses and teaching and registration at a University.

 
There are eight classes, Person, Student, Teacher, Address, Course, Class, and ClassPeriod.
Both teacher and students are people and have first name, last name and address, email address and a phone number. Address is composed of Street Address, City, Province and Postal Code.
Each course has a number, name, and description. A Course are offered as Class, each class defines the course, what are the start and end dates for the class, who is teaching it, what is the class location, a class web page, class days and the class times.   

The code snippet for this example could be as follows

class Address{ string street address; 
string city;
 string province:
 string postalCode;ea
} 
class Person{  string firstName;
 string lastName;
 string emailAddress;
 string phoneNumber;
 Address address;
} 
class Teacher extends Person{    List<class> teaches; }</class>
<class>class Student extends Person {  List<class> registeredIn; }</class></class>
<class><class>class Course {  string number;  string name;  string description; } </class></class>
<class><class>class Class {  Course course;  Teacher teacher;  Date startDate;  Date endDate;  string location;  List<classperiod> classSchedule;  List< registeredStudents; } </classperiod></class></class>
class ClassPeriod {  string day;  time startTime;  time endTime; } 

Back