A Conversation for The Don't Panic Help Centre

object orientated programming with c++

Post 1

Researcher 146911

i am currently researching a paper and have been investigating past examination papers and i am unable to find a suitable aswer to this question.

You have been asked to write a university student marks recording system. The general requirements of the system are straight forward. However, the system must maintain lists of students, where the members of a list are not all on the same course. Students can belong to one of the following courses: HN, BSc, MSc, PhD. The rules that are used to determine if a student passes on each of these courses is different.

A software engineer has suggested that the design for such a program might employ inheritance and a Abstract Base Class. A list of students could then be managed using pointers. Show how this could be done by considering a course pass enquiry for student object described below.

1. Declare an Abstract Base Class called 'Student' that supports a polymorphic pass enquiry. The operation will take the form of a member function called 'pass', which can be assumed to have no parameters and return a boolean value. In your class declaration, give the prototype for the 'pass' function, but do not implement it.

2. Demonstrate hoe 'Student' can be used as a base class to declare different formas of student, such as 'HNStudent' and 'BScStudent'.

3. Give the following object declarations:

HNStudent student1;
BScStudent student2;

Explain with clear examples, how the 'Student' base class and its derived classes are used with pointers to provide the desired polymorphic behavior

GOOD LUCK WITH THIS BRAIN TEASER!!


object orientated programming with c++

Post 2

Is mise Duncan

You'd probably get a better response if you posted this under the "Ask H2G2" forum - this one is mainly for problems with the H2G2 site.
It sound s to me like you're getting us to do your homework, however smiley - smiley...but I don't have a C++ compiler with me and wouldn't want to misinform you, so here's a Visual Basic 5 version you might use as a starting point:

'--[IStudent.cls]------------------------------------------
' Interface definition class for Student
Option Explicit

Public PercentScore As Integer


Public Property Get Pass() As Boolean

End Property

'--[CHnsStudent.cls]---------------------------------------
' Implementation of Student

Option Explicit

Implements IStudent

Dim mPercent As Integer


Private Property Get IStudent_Pass() As Boolean

If IStudent_PercentScore > 50 Then
IStudent_Pass = True
Else
IStudent_Pass = False
End If

End Property

Private Property Let IStudent_PercentScore(ByVal RHS As Integer)

mPercent = RHS

End Property

Private Property Get IStudent_PercentScore() As Integer

IStudent_PercentScore = mPercent

End Property

'--[Students.bas]----------------------------------------------
' Decalarations of students
Dim thisHNSStudent As New CHNSStudent

'..some processing
If thisStudent.Pass Then
MsgBox "Student passed"
Else
MsgBox "Student Failed"
End If

HTH,
<>======uuu======<


object orientated programming with c++

Post 3

Researcher 1973366

This is boring. Please stop showing off.


object orientated programming with c++

Post 4

Is mise Duncan

A fair point and well made.
Thankyou for your valuable input.


object orientated programming with c++

Post 5

Researcher 1973366

You're welcome


object orientated programming with c++

Post 6

Wand'rin star

Why did you bother reading it, then? It wasn't your original Q. Go to something you're interested in. Life's too short to read irrelevant posts.


object orientated programming with c++

Post 7

Is mise Duncan

It was a pretty vague title, though smiley - winkeye


object orientated programming with c++

Post 8

Researcher 1973366

OK, OK, but first of all I didn't know it was boring until I had read it by which time it was too late, secondly I don't see the problem in sticking my nose in, thirdly isn't it Object Oriented Programming not Object Orientated and finally has anyone got a suggestion for a better nickname than Researcher 148398 - my mind's gone a blank. Thank you.


Names..

Post 9

Is mise Duncan

There was something about using the name of your first pet and your mother's maiden name...but that might be when stopped by the Police, so probably not as useful here.

Incidentally, this thread was in completely the wrong forum and none of the Aces have been along to tell us off - are they slacking?


Names..

Post 10

Wand'rin star

What I want to know is what happened to the original questioner.


Names

Post 11

Bizarre Behavior

I was under the impression that only boring people get bored and the most boring person that I can think of is Al Gore. Now, if you concatinate (put together for those people in Canada) those names as Rush Limbaugh has done, you get Algore. This, all by itself, is not a bad nickname... assuming of course that you can be mistaken for a tree and are as boring as a stick.


Key: Complain about this post