Solved

Create componenets, classes

Posted on 1997-03-17
4
140 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
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No problem.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now