Exam Question - Can anyone help
Author Message
Exam Question - Can anyone help

The following question appeared on a computer Science exam paper.  For
anyone who knows anything about Smalltalk it should be pretty easy, as it
only an introductory course.

I am new to smalltalk (or OO in general) and I would be most grateful if
someone could start me me off in the right direction.  A full answer would
be superb.

Thanks a million

Mitch Gardner

P.S  There is a diagram missing from the below, but I have attached a full
ms word document with the full question in.

------------------

CMO 317

(b) Give an implementation for a class OurRectangle, a subclass of Object
whose instances have two instance variables: origin (a Point indicating the
origin of the rectangle) and extent (a vector indicating where the opposite
corner is relative to the origin). Like origin, extent is represented as a
Point. The relationship between the rectangle's origin, corner and extent is
illustrated in the following diagram:

origin

Diagram in attachment . MS Word Format

corner

In your answer you should give the code for the following methods:

Class methods for OurRectangle

origin: o extent: e            Create a new rectangle specified by its
origin (o) and its extent
(e). Both o and e are Points.
origin: o corner: c            Create a new rectangle specified by two
absolute Points: its
origin (o) and the opposite corner
(c).

Instance methods for OurRectangle

origin                                Return the rectangle's origin.
origin: aPoint                   Set the rectangle's origin to aPoint.
extent                                Return the rectangle's extent.
extent: aPoint                   Set the rectangle's extent to aPoint.
corner                                Return the corner opposite the
rectangle's origin
corner: aPoint                   Set the rectangle's corner to be aPoint,
without altering its
origin.
area                                   Return the rectangle's area.
containsPoint: aPoint      Return true if aPoint is within the rectangle;
false otherwise
draw                                  Draw the rectangle on the screen,
using a Pen. You may
assume that the rectangle lies
within the current drawing area
and that the extent is
non-negative.

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help
Hi:

The best start is to look in the image.  You would be suprised.  A great deal
can be gleaned for even a cursory examination.   ;-)

BTW - What makes you think your instructor doesn't read this newsgroup?

Good Luck.

Joseph Bacanskas

Quote:

> The following question appeared on a computer Science exam paper.  For
> anyone who knows anything about smalltalk it should be pretty easy, as it
> only an introductory course.

> I am new to smalltalk (or OO in general) and I would be most grateful if
> someone could start me me off in the right direction.  A full answer would
> be superb.

> Thanks a million

> Mitch Gardner

> P.S  There is a diagram missing from the below, but I have attached a full
> ms word document with the full question in.

> ------------------

> CMO 317

> (b) Give an implementation for a class OurRectangle, a subclass of Object
> whose instances have two instance variables: origin (a Point indicating the
> origin of the rectangle) and extent (a vector indicating where the opposite
> corner is relative to the origin). Like origin, extent is represented as a
> Point. The relationship between the rectangle's origin, corner and extent is
> illustrated in the following diagram:

> origin

> Diagram in attachment . MS Word Format

> corner

> In your answer you should give the code for the following methods:

> Class methods for OurRectangle

> origin: o extent: e            Create a new rectangle specified by its
> origin (o) and its extent
>                                           (e). Both o and e are Points.
> origin: o corner: c            Create a new rectangle specified by two
> absolute Points: its
>                                           origin (o) and the opposite corner
> (c).

> Instance methods for OurRectangle

> origin                                Return the rectangle's origin.
> origin: aPoint                   Set the rectangle's origin to aPoint.
> extent                                Return the rectangle's extent.
> extent: aPoint                   Set the rectangle's extent to aPoint.
> corner                                Return the corner opposite the
> rectangle's origin
> corner: aPoint                   Set the rectangle's corner to be aPoint,
> without altering its
>                                            origin.
> area                                   Return the rectangle's area.
> containsPoint: aPoint      Return true if aPoint is within the rectangle;
> false otherwise
> draw                                  Draw the rectangle on the screen,
> using a Pen. You may
>                                            assume that the rectangle lies
> within the current drawing area
>                                            and that the extent is
> non-negative.

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help
I was wondering if it's ethical to post this kind of question, or to reply
to it.  I've seen several others that seem to be requests for answers to the
homework problems.   I don't mean to pick on Mitch, I don't know what sort
of class it is, or what the ground rules are, but I'd feel better about
helping after there was an attempt to solve the problem, or if the posting
was aimed at some particular aspect of the question.

Am I too old fashioned?
Chas

Quote:

>The following question appeared on a computer Science exam paper.  For
>anyone who knows anything about smalltalk it should be pretty easy, as it
>only an introductory course.

**** snip  ****

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help

Quote:

> Am I too old fashioned?
> Chas

> >The following question appeared on a computer Science exam paper. ...

Not at all.  I think you summed up the common netiquette consensus pretty
well...

- Robb

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help
These are quite interesting responses.  I didn't mean to offend anyone
posting this question, but would like to point out that it is a past
question (from 1997), and that I personally would not risk cheating on an
actual assignment.  I have an exam soon, and am just trying to cover as many
bases as possible to help me prepare.

Mitch

Quote:

> > Am I too old fashioned?
> > Chas

> > >The following question appeared on a computer Science exam paper. ...

> Not at all.  I think you summed up the common netiquette consensus pretty
> well...

> - Robb

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help
Hi:

Perhaps, there is a difference between covering the questions and knowing the
material.

Quote:

> These are quite interesting responses.  I didn't mean to offend anyone
> posting this question, but would like to point out that it is a past
> question (from 1997), and that I personally would not risk cheating on an
> actual assignment.  I have an exam soon, and am just trying to cover as many
> bases as possible to help me prepare.

> Mitch

> > > Am I too old fashioned?
> > > Chas

> > > >The following question appeared on a computer Science exam paper. ...

> > Not at all.  I think you summed up the common netiquette consensus pretty
> > well...

> > - Robb

--
Thanks!!!

Mutual Travel
1201 Third Avenue
Suite 1800
Seattle, WA  98101
USA

v:      206-676-4993
f:      206-676-4666

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help
The news server here at Wolfenet didn't pick up Mitch's second message, but
I'm a bit dubious about it.  As I said the first time, he's made no attempt
to solve it himself.

I'm with Joe until I see a real start.

Chas

Quote:

>Hi:

>Perhaps, there is a difference between covering the questions and knowing
the
>material.

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help
On Sun, 2 May 1999 18:57:11 +0100, "Mitch Gardner"

Mitch, preparation for a test is a good thing.
So how much of this have you tried already?
The problem doesn't look to bad; and hour at most to implement on a
real smalltalk.  Do you have access to a Smalltalk environment to test
this with?
It would be more interesting to look at your work to date & work with
that.  Here's a little bit to get you started (note: the code is
intended as a rough draft; I've tried to leave plenty of room for
improvement...).
John G.

Quote:

>CMO 317

>(b) Give an implementation for a class OurRectangle, a subclass of Object
>whose instances have two instance variables: origin (a Point indicating the
>origin of the rectangle) and extent (a vector indicating where the opposite
>corner is relative to the origin). Like origin, extent is represented as a
>Point. The relationship between the rectangle's origin, corner and extent is
>illustrated in the following diagram:

>origin

>Diagram in attachment . MS Word Format

>corner

>In your answer you should give the code for the following methods:

>Class methods for OurRectangle

I suppose the first thing to do would be how do you create the object
w/its 2 instance variables. I strongly encourage you to work through
this problem w/a real Smalltalk image before taking your test.

OurRectangle class>>#origin: o extent: e
"Answer a new rectangle specified by its
origin (o) and its extent"
| newRect |
newRect := self new.
newRect origin: o.
newRect extent: e.
^newRect

...other class methods deleted...

Quote:
>origin                                Return the rectangle's origin.
>origin: aPoint                   Set the rectangle's origin to aPoint.
>extent                                Return the rectangle's extent.
>extent: aPoint                   Set the rectangle's extent to aPoint.

whoa... if you need help with these, you have to go back and reread
chapter one.  I'm not sure how to briefly explain the difference
between instance variables & accessors.  Look for examples of
getters/setters or accessors in your text's index.

OurRectangle>>#corner
"Return the corner opposite the rectangle's origin"
^self origin + self extent

"this just a guess; I don't have access
to my image at the moment, or i'd test it"

For the area one, consider making some helper methods like lenght &
width.  Then you have
OurRectangle>>#area
^self length * self width

Quote:
>draw                                  Draw the rectangle on the screen,
>using a Pen. You may assume that the rectangle lies
>within the current drawing area and that the extent is
>non-negative.

You're on your own for this one; it varies quite a bit from dialect to
dialect.

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help

Quote:

> These are quite interesting responses.  I didn't mean to offend anyone
> posting this question...

Hi,

Basically you'll find that on any techie newsgroup - at least ones having to do
with programming or math, etc. - there's a cultural guideline about help for
homework or school.  People expect you to first give some honest effort to the
problem before tossing it up to the group.  And then, when you do, make sure
your question is about a specific issue or problem that you have with an
assignment, not just "please solve this".  This is partly motivated by the fact
that we had to do our own work ourselves, that this is better for you, and also
that "please solve this" posts are pretty boring, usually. :)

From "A Primer on How to Work with the Usenet Community":
http://www.netannounce.org/news.announce.newusers/archive/usenet/prim...

----------------

Do not use Usenet as a resource for homework assignments.

Usenet is not a resource for homework or class assignments. A common
new user reaction to learning of all these people out there holding
discussions is to view them as a great resource for gathering
information for reports and papers.  Trouble is, after seeing a few
hundred such requests, most people get tired of them, and won't reply
anyway. Certainly not in the expected or hoped-for numbers. Posting
student questionnaires automatically brands you a "newbie" and does not
usually garner much more than a tiny number of replies.  Further,
some of those replies are likely to be incorrect.

Instead, read the group of interest for a while, and find out what the
main "threads" are - what are people discussing? Are there any themes
you can discover?  Are there different schools of thought?

Only post something after you've followed the group for a few weeks,
after you have read the Frequently Asked Questions posting if the group
has one, and if you still have a question or opinion that others will
probably find interesting.  If you have something interesting to
contribute, you'll find that you gain almost instant acceptance, and
your posting will generate a large number of follow-up postings. Use
these in your research; it is a far more efficient (and accepted) way
to learn about the group than to follow that first instinct and post a
simple questionnaire.

--------------------

- Robb

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help

Quote:

>I was wondering if it's ethical to post this kind of question, or to
>to it.  I've seen several others that seem to be requests for answers
>to the
>homework problems.

I think  experienced people should give a friendly warning
that University authorities come down {*filter*} students who ask directly
for
answers. Speaking for myself,  I think it reasonable that students
should be
able to ask for guidance, and only reasonable for us to give guidance.
As a
previous poster argued, we should give quick and useful guidance to any
novices
posting to this group, only then will we be perceived as an 'ethical'
community
and only then will we get the Smalltalk community to grow.

Wed, 18 Jun 1902 08:00:00 GMT
Exam Question - Can anyone help

Quote:

>These are quite interesting responses.  I didn't mean to offend anyone
>posting this question, but would like to point out that it is a past
>question (from 1997), and that I personally would not risk cheating on an
>actual assignment.  I have an exam soon, and am just trying to cover as
many
>bases as possible to help me prepare.

A laudable intention, I'm sure.  However, reading code written by someone
else will do far less good than actually writing it yourself.  As you said
in your first message, it's an easy assignment (which is what one would
expect on an exam) and should take no more than half an hour or so.  Have
at, and we'll all be interested to see what you come up with.
--
Bob Jarvis
Mail address hacked to foil spammers!