comp.lang.ada
 help / color / mirror / Atom feed
* Re: Ada Student Needs Help..
  1997-01-13  0:00 Ada Student Needs Help baker
@ 1997-01-13  0:00 ` Larry Kilgallen
  1997-01-13  0:00   ` Norman H. Cohen
                     ` (4 more replies)
  1997-01-16  0:00 ` John English
  1 sibling, 5 replies; 10+ messages in thread
From: Larry Kilgallen @ 1997-01-13  0:00 UTC (permalink / raw)



In article <5bdl4i$ffl@saturn.brighton.ac.uk>, jmb36@bton.ac.uk (baker) writes:
> I'm a Computer Science student in my first term. I've got a problem that I
> hope you can help me with. From the chart below, I need to be able to mix
> a selection of drinks (or just one drink) and display the total alcoholic
> content in standard units of 10 millilitres. I'm stuck on how to do this.
> Can anyone help me out?

In general, however, helping people with their schoolwork is frowned
upon within comp.lang.ada.

> I just want a genral solution, hopefully avoiding arrays (cos I'm not very
> good with them) Can I use Record types?

If you aren't very good with arrays, that might be a good reason to
use them for your project, since the goal is learning rather than
actually mixing drinks.

However, I might be wrong about that, since I am not in the
Education business.

Larry Kilgallen




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Ada Student Needs Help..
@ 1997-01-13  0:00 baker
  1997-01-13  0:00 ` Larry Kilgallen
  1997-01-16  0:00 ` John English
  0 siblings, 2 replies; 10+ messages in thread
From: baker @ 1997-01-13  0:00 UTC (permalink / raw)



I'm a Computer Science student in my first term. I've got a problem that I
hope you can help me with. From the chart below, I need to be able to mix
a selection of drinks (or just one drink) and display the total alcoholic
content in standard units of 10 millilitres. I'm stuck on how to do this.
Can anyone help me out?

Berverage        Standard Strength    Bottle/Can ml     Standard Pub Glass

 Beer               3.5                   440                568 (pint)
 Strong Beer        5.0                   
 Wine               12.0                  750                125
 Fortified Wine     18.0                  750                50
 Spirits            40.0                  700                24


I just want a genral solution, hopefully avoiding arrays (cos I'm not very
good with them) Can I use Record types?

Please could you E-Mail me at J.M.Baker@bton.ac.uk

Thanks

Rage Matrix.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-13  0:00 ` Larry Kilgallen
@ 1997-01-13  0:00   ` Norman H. Cohen
  1997-01-14  0:00   ` Michael F Brenner
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Norman H. Cohen @ 1997-01-13  0:00 UTC (permalink / raw)



Larry Kilgallen wrote:

> If you aren't very good with arrays, that might be a good reason to
> use them for your project, since the goal is learning rather than
> actually mixing drinks.

My understanding is that the relative importance of learning and of
mixing drinks varies greatly from one campus to another.

-- 
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-13  0:00 ` Larry Kilgallen
  1997-01-13  0:00   ` Norman H. Cohen
@ 1997-01-14  0:00   ` Michael F Brenner
  1997-01-17  0:00   ` Steve Jones - JON
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Michael F Brenner @ 1997-01-14  0:00 UTC (permalink / raw)



Yes, Rage Matrix, you can use record types.
 
We presume that you are spelling Berverage as you did to avoid 
speculation that you or your instructor partake or preach partakement
in Beverages.

In setting up the objects and methods for your program architecture,
you will probably decide to have an object called a Drink which 
sends messages to objects called Berverages. The messages ask questions
like <what is thy percentage alcohol>, <thy volume in ml>, and <thy 
serving size in ml>. From the responses to these messages you could 
compute the number of 10 ml doses of alcohol the imbiber injests. So 
far, no record types or arrays at all. However, INSIDE the methods 
that ask the questions of the Berverage objects, there will be some
kind of data structure which stores the table of strengths and volumes.
This table can be done in several different ways, and you will have
to make two choices. 

First, the abstract data type to use for the Berverages
must be selected, for example, a record type, an array,
a character string, a linked list, a double linked list, a heap,
a balanced or semi-balanced tree, a graph, an unordered set of tuples
or associative array, a relational database, a sequential disk file,
a random disk file, a human-in-the-loop help desk, a CGI Net search,
a data mining encyclopedia CD-ROM search application, an electronic
interface to a chemical measuring tool, a punched card or paper tape
reader, an indexed sequential floppy dataset, a multiplicative group
based on a numerical generating function, a polynomial approximation,
a dynamic system (with or without chaos), a voice recognition circuit
that rings the 900 hundred phone number for Bartenders anonymous, or
an interface to your robot who knocks up the local pub and gets advice.

Second, the abstract data type to use for the table itself must be selected,
from the list above or others. Actually, there is a data type called a
two-dimensional array which would be a single data structure that takes
the place of the individual data types for the Berverages and the Table
above.

Next, you code the test programs to exercise these data structures
completely.

Finally, you fill in the code for the methods used by the ADTs you have
chosen. The best way to do this is to reuse code from existing libraries,
for example, the PAL. That way you dont actually have to program any
arrays or record types at all. Programming data types is the most fruitful
source of bugs in languages like Ada where you dont use pointers or go_tos.
If you reuse every data structure, you can just do applications level
programming from your operating environment. Another way of reusing code
is dynamically loaded through your operating environment, for example, 
dynamically load the table type through CORBA from another computer that
happens to have the volumes and strengths already loaded, such as the
UBREW brewery in Ottawa, Ontario, Canada that makes this beer and wine
information available through the Algae Gateway at the Net address
http://www.synapse.net/~fti/al.htm. If you absolutely refuse to reuse
the code for your abstract data structures, then you could read a good
book on how to do arrays, such as Edsger Dijkstra, Discipline of Programming.
An example of the code for implementing an array reference to get the
number of millilitres in each container of Berverage is as follows:

    type container_volumes is array (berverages) of ounces; 
    container_volume: constant container_volumes := (8, 16, 20);
    
    function volume (berverage: berverages) return millilitres is

      -- precondition: The container volume array has been 
      --               initialized with an entry for berverage,
      --               which, when multiplied by the number of
      --               millilitres_per_ounce, will not overflow
      --               millilitres'last.

      container: constant ounces := container_volume (berverage);
      berverage_volume: constant millilitres :=
        millilitres_per_ounce * container;
    begin
      -- invariant: If the program counter has arrived at this point
      -- in the program, then the berverage_volume is the number of 
      -- millilitres in one container of the requested berverage.

      return berverage_volume;                    
    end volume; 

Coding arrays is like learning algebra, it requires lots of practice
to get the preconditions and invariants correctly, and in some cases,
to ensure termination of the loops. I recommend a lot of practice,
and a lot of tolerance for an educational system that does not teach
programming by giving you lots of examples of working code, and 
methods of modifying that code to do what you want. Attempting to 
program an array from scratch is bound to result in many frustrating
false starts.
 




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-13  0:00 Ada Student Needs Help baker
  1997-01-13  0:00 ` Larry Kilgallen
@ 1997-01-16  0:00 ` John English
  1997-01-16  0:00   ` Larry Kilgallen
  1997-01-16  0:00   ` whiting_ms@corning.com (Matt Whiting)
  1 sibling, 2 replies; 10+ messages in thread
From: John English @ 1997-01-16  0:00 UTC (permalink / raw)



baker (jmb36@bton.ac.uk) wrote:
: I'm a Computer Science student in my first term. I've got a problem that I
: hope you can help me with. From the chart below, I need to be able to mix
: a selection of drinks (or just one drink) and display the total alcoholic
: content in standard units of 10 millilitres. I'm stuck on how to do this.
: Can anyone help me out?

Well, you could always go and ask the lecturer (me, that is :-)
I assume you know where my office is.  But be quick, the hand-in
date is next Thursday!

:-) :-)

---------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | fax: (+44) 1273 642405
 University of Brighton    |
---------------------------------------------------------------




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-16  0:00 ` John English
  1997-01-16  0:00   ` Larry Kilgallen
@ 1997-01-16  0:00   ` whiting_ms@corning.com (Matt Whiting)
  1 sibling, 0 replies; 10+ messages in thread
From: whiting_ms@corning.com (Matt Whiting) @ 1997-01-16  0:00 UTC (permalink / raw)



In article <5bld1m$h8u@saturn.brighton.ac.uk>, je@bton.ac.uk (John English) writes:
> baker (jmb36@bton.ac.uk) wrote:
> : I'm a Computer Science student in my first term. I've got a problem that I
> : hope you can help me with. From the chart below, I need to be able to mix
> : a selection of drinks (or just one drink) and display the total alcoholic
> : content in standard units of 10 millilitres. I'm stuck on how to do this.
> : Can anyone help me out?
> 
> Well, you could always go and ask the lecturer (me, that is :-)
> I assume you know where my office is.  But be quick, the hand-in
> date is next Thursday!
> 
> :-) :-)
> 
--
Don't you just hate it when this happens!  :-) 

Matt




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-16  0:00 ` John English
@ 1997-01-16  0:00   ` Larry Kilgallen
  1997-01-16  0:00   ` whiting_ms@corning.com (Matt Whiting)
  1 sibling, 0 replies; 10+ messages in thread
From: Larry Kilgallen @ 1997-01-16  0:00 UTC (permalink / raw)



In article <5bld1m$h8u@saturn.brighton.ac.uk>, je@bton.ac.uk (John English) writes:
> baker (jmb36@bton.ac.uk) wrote:
> : I'm a Computer Science student in my first term. I've got a problem that I
> : hope you can help me with. From the chart below, I need to be able to mix
> : a selection of drinks (or just one drink) and display the total alcoholic
> : content in standard units of 10 millilitres. I'm stuck on how to do this.
> : Can anyone help me out?
> 
> Well, you could always go and ask the lecturer (me, that is :-)
> I assume you know where my office is.  But be quick, the hand-in
> date is next Thursday!

In the true spirit of Ada, John English has provided tagged types
for class problems, presuming other educators have not assigned
drink-mixing problems this month ;-)

Larry Kilgallen




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-13  0:00 ` Larry Kilgallen
                     ` (2 preceding siblings ...)
  1997-01-17  0:00   ` Steve Jones - JON
@ 1997-01-17  0:00   ` John English
  1997-01-17  0:00   ` Steve Jones - JON
  4 siblings, 0 replies; 10+ messages in thread
From: John English @ 1997-01-17  0:00 UTC (permalink / raw)



Larry Kilgallen (kilgallen@eisner.decus.org) wrote:
: In article <5bdl4i$ffl@saturn.brighton.ac.uk>, jmb36@bton.ac.uk (baker) writes:
: > I just want a genral solution, hopefully avoiding arrays (cos I'm not very
: > good with them) Can I use Record types?

: If you aren't very good with arrays, that might be a good reason to
: use them for your project, since the goal is learning rather than
: actually mixing drinks.

Well said, Larry, you took the words out of my mouth.

: However, I might be wrong about that, since I am not in the
: Education business.

You're not wrong -- not wrong at all!

---------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | fax: (+44) 1273 642405
 University of Brighton    |
---------------------------------------------------------------




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-13  0:00 ` Larry Kilgallen
                     ` (3 preceding siblings ...)
  1997-01-17  0:00   ` John English
@ 1997-01-17  0:00   ` Steve Jones - JON
  4 siblings, 0 replies; 10+ messages in thread
From: Steve Jones - JON @ 1997-01-17  0:00 UTC (permalink / raw)



je@bton.ac.uk (John English) writes:

> 
> Larry Kilgallen (kilgallen@eisner.decus.org) wrote:
> : In article <5bdl4i$ffl@saturn.brighton.ac.uk>, jmb36@bton.ac.uk (baker) writes:
> : > I just want a genral solution, hopefully avoiding arrays (cos I'm not very
> : > good with them) Can I use Record types?
> 
> : If you aren't very good with arrays, that might be a good reason to
> : use them for your project, since the goal is learning rather than
> : actually mixing drinks.
> 
> Well said, Larry, you took the words out of my mouth.
> 
> : However, I might be wrong about that, since I am not in the
> : Education business.
> 
> You're not wrong -- not wrong at all!

Added to this the student has now raised the issue that if he doesn't
use arrays he is admitting defeat. Next project... a generic matrix
multiplication packge for NxN(xN etc :) arrays.

Reminds me of a student who disagreed with my fathers marking, my father
admitted he was wrong in that case but pointed out 5 other places
where he really should have docked marks so the student ended up with
plus a few and minus more.


-- 
Un Lupe en France  | Cat 1, Cha, Cha, Cha -- NERC offical drinking song
----The above of opinions rarely reflect my own and never my employers------
Do not add me to mailing lists violations will be billed for time.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Ada Student Needs Help..
  1997-01-13  0:00 ` Larry Kilgallen
  1997-01-13  0:00   ` Norman H. Cohen
  1997-01-14  0:00   ` Michael F Brenner
@ 1997-01-17  0:00   ` Steve Jones - JON
  1997-01-17  0:00   ` John English
  1997-01-17  0:00   ` Steve Jones - JON
  4 siblings, 0 replies; 10+ messages in thread
From: Steve Jones - JON @ 1997-01-17  0:00 UTC (permalink / raw)



je@bton.ac.uk (John English) writes:

> 
> Larry Kilgallen (kilgallen@eisner.decus.org) wrote:
> : In article <5bdl4i$ffl@saturn.brighton.ac.uk>, jmb36@bton.ac.uk (baker) writes:
> : > I just want a genral solution, hopefully avoiding arrays (cos I'm not very
> : > good with them) Can I use Record types?
> 
> : If you aren't very good with arrays, that might be a good reason to
> : use them for your project, since the goal is learning rather than
> : actually mixing drinks.
> 
> Well said, Larry, you took the words out of my mouth.
> 
> : However, I might be wrong about that, since I am not in the
> : Education business.
> 
> You're not wrong -- not wrong at all!

Added to this the student has now raised the issue that if he doesn't
use arrays he is admitting defeat. Next project... a generic matrix
multiplication packge for NxN(xN etc :) arrays.

Reminds me of a student who disagreed with my fathers marking, my father
admitted he was wrong in that case but pointed out 5 other places
where he really should have docked marks so the student ended up with
plus a few and minus more.


-- 
Un Lupe en France  | Cat 1, Cha, Cha, Cha -- NERC offical drinking song
----The above of opinions rarely reflect my own and never my employers------
Do not add me to mailing lists violations will be billed for time.





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1997-01-17  0:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-13  0:00 Ada Student Needs Help baker
1997-01-13  0:00 ` Larry Kilgallen
1997-01-13  0:00   ` Norman H. Cohen
1997-01-14  0:00   ` Michael F Brenner
1997-01-17  0:00   ` Steve Jones - JON
1997-01-17  0:00   ` John English
1997-01-17  0:00   ` Steve Jones - JON
1997-01-16  0:00 ` John English
1997-01-16  0:00   ` Larry Kilgallen
1997-01-16  0:00   ` whiting_ms@corning.com (Matt Whiting)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox