comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada stacks and the time system
Date: Mon, 16 Sep 2019 11:14:44 +0300
Date: 2019-09-16T11:14:44+03:00	[thread overview]
Message-ID: <gu8ujiFfg7pU1@mid.individual.net> (raw)
In-Reply-To: <8c293e09-fc74-45a4-b109-cd4041a4a311@googlegroups.com>

Is this a homework problem? Sounds like the kind of lame humour some of 
them use.

On 19-09-16 09:39 , sandeep parajuli wrote:
> Emperor Constantine has commanded Darth Vader to build and operate a
> warship repair facility for Tie Fighters and Star Destroyers.  When a
> damaged vehicle arrives a service record must be placed in the
> appropriate service bay

How many service bays can there be? An unlimited number? How are they 
identified, in case the program should keep track of several bays at the 
same time?

> including the vehicles name and time of
> arrival.  For security reasons, Tie fighters are assigned names of
> TieA, TieB etcetera.  Likewise, Star Destroyers are given names of
> StarA, StarB etcetera.  After a vehicles name ends in ‘Z’ the
> sequence is repeated from ‘A’.

Oops, a built-in "26-ship-wrap-around-problem" right there...

>  Lord Vader directed us to write a
> program for the facility providing support for two stacks or parish

What does a church parish have to do with it? Oh, I guess you meant 
"perish".

What are the "stacks" for? To store the service records? Why should they 
be "stacks" (last-in-first-out)? It seems much more likely that ships 
follow a queue order (first-in-first-out). Why are there two stacks? Is 
one for the Ties and the other for the Stars?

> in the attempt.  To minimize waste, the two stacks must occupy the
> same physical space, for example locations 1 through 20 for the “C”
> Option.

What is the "C" Option? To use the C language instead of Ada?

What are these "locations" that you speak of? Elements in an array, perhaps?

Where does the number 20 come from? Is this the largest number of 
vehicles (Ties or Stars) that can be under repair at the same time in 
any one service bay? Ah, I see that it is explained a little later in 
your posting.

> The stack space must be allocated dynamically in the stack,
> not the heap (Box1.ada)!  You must prompt the user at run time for
> the upper and lower array bounds.  For the “C” option use 1 and 20 as
> the lower and upper bounds for the actual space used to track
> vehicles, i.e., the stack space will hold a maximum of 20 space
> vehicles.  The following memory model was specified by Lord Vader
> using 1 and 20 for the lower and upper bounds respectively.

What "following memory model"?

> How can we do this is Ada

I am tempted to answer: by studying the Ada language and then writing 
the program. Have you even thought about it? Do you know how to 
implement any part of it in Ada, for example prompting for and receiving 
the lower and upper bounds? Which part do you not know how to solve? Can 
you solve it in the C language? If so, can you map your C solution to an 
Ada solution?

As it seems to be a homework problem, I will of course not give you a 
complete solution. But I will give you one hint: to store two stacks in 
the "same" space, such as an array of a given size, a method already 
known to the ancients of computing is to make one stack start at the 
low-index end of the array and grow towards higher indices, while the 
other stack starts at the high-index end of the array and grows towards 
lower indices. Of course this means that the sum of the sizes of the two 
stacks cannot exceed the length of the array, but that seems to be 
exactly how "lord Vader" has set up the problem.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  reply	other threads:[~2019-09-16  8:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16  6:39 Ada stacks and the time system sandeep parajuli
2019-09-16  8:14 ` Niklas Holsti [this message]
2019-09-16 16:02 ` Dennis Lee Bieber
2019-09-18 19:09 ` Ludovic Brenta
replies disabled

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