Solved

Create componenets, classes

Posted on 1997-03-17
4
162 Views
Last Modified: 2010-04-04
I gotta write a program to enroll students, print listings
,... Should I create my own components, classes??
How??
0
Comment
Question by:940216td
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 100 total points
ID: 1334805
I hope you don't expect me to write all the code for you, but I will give you some possible choices and some places to look in the help files.

First, I don't think you'll need to design your own components.  Classes, yes, I think you'll have to design a few classes to encapsulate your program's functionality.

I'm going to presume that you know how to design Delphi classes.  If you don't, then perhaps you need to pick up a good book and start reading about this stuff.

You're probably going to want to store all of this class/student/enrollment data in a database.  I'd suggest Paradox, since Delphi easily interfaces with Paradox (both being Borland products, it seems natural).  There are a couple of good examples in the Delphi docs and there are a slew of books on how it is all accompished.  If you don't have one, pick one up.

As for classes...well, I'd guess that you'd need a class based upon each school segment (semester/trimester/quarter), a class based upon a Course, and a class for Students.  I'll outline each in a very basic manner to get you started:

CSemester = class
   Date: String;  //perhaps something like Winter97 would be
                    stored here.
   Courses: TList; //this will contain all courses offered
                     during a semester.
   procedure AddCourse(c: CCourse);
   procedure DeleteCourse(c: Course);
   procedure UpdateCourse(various parameters);
end;

CCourse = class
   Name: String;  //the name of the course, BIOL201
   Students: TList;  // this will contain all students enrolled
                        in a particular course.
   WaitList: TList; //list of all students who enrolled after the
                      course became full.
   PreReqs: TList; // this will list all courses that are
                      required for this course.
   MaxEnroll: Integer; //this will say how many students may
                         enroll before course becomes full.
   IsFull: Boolean; //a flag that states whether course is full
   procedure AddStudent(s: CStudent);
   function CheckPreReqs(s: Student): Boolean; //this will check
                               whether a student has the required
                               prereqs before enrolling.
end;

CStudent = class
  ID:  Cardinal; // the student number
  Name: TStudentName;  // a record with fields such as last
                          name, first name
  Address: TAddress; // a record with fields such as street,
                        city, province, postal code
  Courses: TList; // a list of all courses that the student has
                     enrolled in and received credit (passed).
end;

All of these classes will have to access the database.  Perhaps you'll have tables that match the classes and that cross reference each other.

You'll have to read a about TLists, one of the handiest, most often used features of Delphi (at least by me).  If you use TLists, then you'll have to understand pointers.  The Delphi help files have some pretty good examples on TLists.

I'd recommend some books for you, but I don't own any.  I've learned all my Delphi from the help files (80%) and the rest from reading the newsgroups and asking questions on them.  This place (Experts-Exchange) is pretty good for that too.

The type of program you are writing can become quite involved and can become quite complex.  I certainly don't want to deter you, but there are a lot of features you'll have to know about in Delphi that will end up making your job a lot easier and the code a lot simpler to maintain.

What you are asking is very very broad and a book could be written about it.  Hopefully I've given you a few ideas so that you know where to start and where to go for more information.
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1334806
Clarification:

 In the CCourse class....

    Students and WaitList would be TLists holding items
    of type CStudent.
   
    PreReqs would be a TList of type string...something
    that would match the Name property in another CCourse
    object.

 In CStudent....

    Courses would be a TList holding data of type CCourse.
    Though a string matching a Name in a CCourse object
    would be fine too.

These classes are rough and are off the top of my head.
They are not complete and they may not be the best design.
But hopefully I've got you going in the right direction.

I presume this is for a school project?  You name here
looks like a student number...like the type they give
Comp students at universities and such.

Cheers,
0
 

Author Comment

by:940216td
ID: 1334807
Thanx a lot, I'm going to study this proposal now and see where it gets me. I hope you can help me more if I'm stuck.
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1334808
No problem.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question