Connecting Tech Pros Worldwide Forums | Help | Site Map

class

triplejump24
Guest
 
Posts: n/a
#1: Dec 11 '06
Hello. Im working on what seems to me a very complicated programming
assignment. I basically have to design a video library using class. The
program needs to read data files i have and put the into in arrays. I have
to be able ot check out a video, check in a video, get video info, get
customer info. Theres alot of steps but i dont need to do all of them to
get the points i need. If anyone has anytime to help me i would really
really really would appreciate it. Just email me and i will definitely get
back to you promptly. Thanks again


santosh
Guest
 
Posts: n/a
#2: Dec 11 '06

re: class


triplejump24 wrote:
Quote:
Hello. Im working on what seems to me a very complicated programming
assignment. I basically have to design a video library using class.
<snip>

If your project is to be in C++, (judging by the word 'class' above),
then this is the wrong group. Post to comp.lang.c++.

CBFalconer
Guest
 
Posts: n/a
#3: Dec 11 '06

re: class


triplejump24 wrote:
Quote:
>
Hello. Im working on what seems to me a very complicated programming
assignment. I basically have to design a video library using class.
The program needs to read data files i have and put the into in
arrays. I have to be able ot check out a video, check in a video,
get video info, get customer info. Theres alot of steps but i dont
need to do all of them to get the points i need. If anyone has
anytime to help me i would really really really would appreciate it.
Just email me and i will definitely get back to you promptly.
The ISO standard C language knows naught about videos, classes,
check ins, customer info, etc. Look for an appropriate newsgroup.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

Richard Heathfield
Guest
 
Posts: n/a
#4: Dec 11 '06

re: class


triplejump24 said:
Quote:
Hello. Im working on what seems to me a very complicated programming
assignment. I basically have to design a video library using class.
It's not actually that bad, believe it or not, but I can see why you might
find it a bit daunting.

If by "class" you mean a C++-style class, you're in the wrong newsgroup, and
you might want to ask in alt.comp.lang.learn.c-c++ instead. If you are in
fact learning C, then you need to know it doesn't have a "class" keyword.
It does, however, have a "struct" keyword which does basically the same job
- aggregating elements together - in a less syntactic-sugary way.
Quote:
The
program needs to read data files i have and put the into in arrays. I have
to be able ot check out a video, check in a video, get video info, get
customer info.
That's a reasonable description of about 90% of programming tasks!
It used to be called Create/Retrieve/Amend/Purge (or, alternatively,
Create/Retrieve/Update/Delete). (Yes, folks - Theodore's Caviare.)
Quote:
Theres alot of steps but i dont need to do all of them to
get the points i need. If anyone has anytime to help me i would really
really really would appreciate it.
I'll start you off:

int main(void)
{
return 0;
}

but we don't do your homework for you. What we *will* do is help you to
understand and fix your own code. For example, the problem with the above
code is that it doesn't do anything! So your first job should be to write a
function to display a menu of choices. Let the first choice you implement
be "End program". And your second job should be to capture a menu choice
from stdin and do something with it - call a stub (dummy) function, say,
or, in the case of the "End program" choice, quit the program.

Quote:
Just email me
Post here, read here.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Bill Reid
Guest
 
Posts: n/a
#5: Dec 11 '06

re: class



Richard Heathfield <rjh@see.sig.invalidwrote in message
news:N6qdnaM2LbREkuDYnZ2dnUVZ8tmhnZ2d@bt.com...
Quote:
triplejump24 said:
>
Quote:
Hello. Im working on what seems to me a very complicated programming
assignment. I basically have to design a video library using class.
>
It's not actually that bad, believe it or not, but I can see why you might
find it a bit daunting.
>
It DOES exceed the complexity level of knowing the return value
of main()...
Quote:
If by "class" you mean a C++-style class, you're in the wrong newsgroup,
and
Quote:
you might want to ask in alt.comp.lang.learn.c-c++ instead. If you are in
fact learning C, then you need to know it doesn't have a "class" keyword.
It does, however, have a "struct" keyword which does basically the same
job
Quote:
- aggregating elements together - in a less syntactic-sugary way.
Heh. OK, I'll play...but let's be clear, this DOES seem to be a
classic "object-oriented programming" educational exercise (I actually
took this same basic "test" in what was the only formal programming
"class" I ever took, a two-day seminar on OOP), and there actually IS
an "A" answer (and an "F" answer, which is what most "C"
programmers get when they take it)...
Quote:
>
Quote:
The
program needs to read data files i have and put the into in arrays. I
have
Quote:
Quote:
to be able ot check out a video, check in a video, get video info, get
customer info.
>
I'll start you off:
>
int main(void)
{
return 0;
}
>
How do you know he doesn't get "points" for command-line
arguments?
Quote:
but we don't do your homework for you.
But we will help you do it wrong?
Quote:
For example, the problem with the above
code is that it doesn't do anything!
Man, have you got the wrong idea here...
Quote:
So your first job should be to write a
function to display a menu of choices.
Wrong. Wrong, wrong, wrong, so totally wrong...I can't say
for sure, but I'll bet he gets ZERO points for writing essentially
a "Hello World!" program...

OK, you assert that you can do object-oriented programming in
C, I'm not going to dispute that. What I must dispute is that when
starting an object-oriented programming task, you start by designing
a menu! Obviously, your particular "orientation" is anything BUT
"object-"...

What he really needs to do FIRST is to think about how to "classify"
objects in his program. So your first "structure" (or "class") you can
"design" on a piece of paper, nowhere near a computer. You just
write down the defining characteristics of a "video", how you actually
distinguish between different "videos" in the context of this program.
He apparently already has data files with this information, so he can
pretty much just look at those files and go from there. Now he
knows what his "video" structure (or class) will contain; he can
sit down at a computer and type the structure declaration into
a *.c (*.cpp, *.C?) file.

Then he can declare an array of these structures...he seems to be
sort of limited by the stated problem to only use an array, but really
it would be better to declare another "library" structure that contains the
array of videos (or pointer) with some additional information, such as
the total number of videos, etc., and to get really OOP, sort of an
extension of the "video" class to include information on whether
video has been checked out, etc.

And the next class is the video store "clerk", and that class
will largely be a series of declarations of functions that scan
through the extended array of videos to find titles, check
whether they have been checked out, check them out, etc.
This is the "class" that actually DOES something, but in
true OOP we FIRST figure out what the data is that we
will be manipulating, THEN we figure out how to manipulate
it. It actually is simpler and quicker to do it this way in
many cases...

After you've done all that, you're actually about 70% done writing
the program, and you actually didn't have to come close to a computer!
And of course, as your LAST declaration, you can include some user
interface menu functions in the video store "clerk" class!
Quote:
Let the first choice you implement
be "End program". And your second job should be to capture a menu choice
from stdin and do something with it - call a stub (dummy) function, say,
or, in the case of the "End program" choice, quit the program.
>
Talk about code that doesn't do anything...

---
William Ernest Reid



Richard Heathfield
Guest
 
Posts: n/a
#6: Dec 11 '06

re: class


Bill Reid said:
Quote:
>
Richard Heathfield <rjh@see.sig.invalidwrote in message
news:N6qdnaM2LbREkuDYnZ2dnUVZ8tmhnZ2d@bt.com...
<snip>
Quote:
Quote:
>If by "class" you mean a C++-style class, you're in the wrong newsgroup,
and
Quote:
>you might want to ask in alt.comp.lang.learn.c-c++ instead. If you are in
>fact learning C, then you need to know it doesn't have a "class" keyword.
>It does, however, have a "struct" keyword which does basically the same
job
Quote:
>- aggregating elements together - in a less syntactic-sugary way.
>
Heh. OK, I'll play...but let's be clear, this DOES seem to be a
classic "object-oriented programming" educational exercise
....and your entire reply is based on that premise. Nevertheless, he posted
in comp.lang.c, and so I gave a C-based reply (*after* first saying that if
he is using C++ he should check aclcc++, which in fact he has now done).

You mocked my "top-down" approach, and that's your right, but it would have
been perfectly suitable for this program. Your "bottom-up" approach is fine
too, of course, but top-down has the great advantage that it allows the
programmer to produce visible results quite quickly, and that can be very
encouraging to a neophyte.

<snip>

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Bill Reid
Guest
 
Posts: n/a
#7: Dec 29 '06

re: class



Richard Heathfield <rjh@see.sig.invalidwrote in message
news:aaCdnUgqRtIzCeDYnZ2dnUVZ8qCqnZ2d@bt.com...
Quote:
Bill Reid said:
>
Quote:

Richard Heathfield <rjh@see.sig.invalidwrote in message
news:N6qdnaM2LbREkuDYnZ2dnUVZ8tmhnZ2d@bt.com...
>
<snip>
>
Quote:
Quote:
If by "class" you mean a C++-style class, you're in the wrong
newsgroup,
Quote:
Quote:
and
Quote:
you might want to ask in alt.comp.lang.learn.c-c++ instead. If you are
in
Quote:
Quote:
Quote:
fact learning C, then you need to know it doesn't have a "class"
keyword.
Quote:
Quote:
Quote:
It does, however, have a "struct" keyword which does basically the same
job
Quote:
- aggregating elements together - in a less syntactic-sugary way.
Heh. OK, I'll play...but let's be clear, this DOES seem to be a
classic "object-oriented programming" educational exercise
>
...and your entire reply is based on that premise.
Well, not entirely, because being "object-oriented" is actually
a way of THINKING about creating a program that performs
a particular task.
Quote:
Nevertheless, he posted
in comp.lang.c, and so I gave a C-based reply (*after* first saying that
if
Quote:
he is using C++ he should check aclcc++, which in fact he has now done).
>
Even when programming strictly in "C", I tend to first just write or
type out all the variables I think I'll need off the top of my head, and
the function "declarations" needed to manipulate the data. This can
probably be thought of as "data-oriented" programming, and I'll
immediately notice that certain variables all fall into certain categories
that I'll be using for certain types of functions, and at that point
I know that I'll want to group all those variables into a structure
and pass them as a pointer to the functions.

So again, no matter what the language, I wind up writing a lot
of the "code" before I even need to turn on a computer. I do find
this is quicker than just starting writing code that produces "visible"
but simple results, because I typically find that then I have to go
back and re-write all that stuff anyway to actually solve the problem
in the first place...
Quote:
You mocked my "top-down" approach, and that's your right, but it would
have
Quote:
been perfectly suitable for this program.
Well, my actual response has been excised from this post, but I
did specifically relate it to real-world "object-oriented" classroom
exercise where it would have been unsuitable in the sense that it
would have received a failing grade. But who really knows what's
going on the mind of the teacher of HIS class; maybe "flashy lights"
alone WOULD pass.
Quote:
Your "bottom-up" approach is fine
I'm also not sure why you refer to "object-orientation" as a "bottom-up"
process, since the process is actually one of conceptually moving from the
most general classification of the world to as specific as needed to
complete
the program. I think your actual conceptual framework is so completely
non-object-oriented, so rigidly linear in nature, that you equate "input"
and
"output" as the "top" and "bottom" of a program, hence you refer writing
a "menu" ("input") first as a "top-down" approach. My point was that
we already know conceptually what the "menu" is in the first place, so
if we write that first we are neither at the "top" or "bottom" but actually
have done NOTHING to solve the problem...
Quote:
too, of course, but top-down has the great advantage that it allows the
programmer to produce visible results quite quickly, and that can be very
encouraging to a neophyte.
>
Well, this is true, myfirstprogram.c is always "Hello World!", innit?
But if you can't get beyond that, it might as well be your last...

---
William Ernest Reid



Richard Heathfield
Guest
 
Posts: n/a
#8: Dec 29 '06

re: class


Bill Reid said:

<snip>
Quote:
I think your actual conceptual framework is so completely
non-object-oriented, so rigidly linear in nature, that you equate "input"
and
"output" as the "top" and "bottom" of a program, hence you refer writing
a "menu" ("input") first as a "top-down" approach.
Well, it isn't, and I don't, and I didn't. To be more specific, I most
certainly do not confuse "input" with "top" or "output" with "bottom".

<snip>
Quote:
Quote:
>too, of course, but top-down has the great advantage that it allows the
>programmer to produce visible results quite quickly, and that can be very
>encouraging to a neophyte.
>>
Well, this is true, myfirstprogram.c is always "Hello World!", innit?
Yes, and there's a good reason for that.
Quote:
But if you can't get beyond that, it might as well be your last...
"Okay, kid, you've had your first faltering steps towards your daddy, so now
let's see you running that marathon..."

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Closed Thread