comp.lang.ada
 help / color / mirror / Atom feed
From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject: Re: Ada stacks and the time system
Date: Mon, 16 Sep 2019 12:02:44 -0400
Date: 2019-09-16T12:02:44-04:00	[thread overview]
Message-ID: <7iavne5pj826nf5felshia363dl778k9am@4ax.com> (raw)
In-Reply-To: 8c293e09-fc74-45a4-b109-cd4041a4a311@googlegroups.com

On Sun, 15 Sep 2019 23:39:53 -0700 (PDT), sandeep parajuli
<parajulisandeep.sp205168@gmail.com> declaimed the following:

>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 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’.  Lord Vader directed us to write a program for the facility providing support for two stacks or parish 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.  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.
>
>How can we do this is Ada


	This reads like a homework assignment -- and one should not expect to
receive answers to homework itself.

	Show us what you've done, pointing out where you are stuck, and we'll
often provide hints for that specific point.

	Are these names permanently assigned to each ship, or are they assigned
when the ship arrives and "forgotten" once the repair is completed and the
ship leaves the facility (meaning the same ship could come in a second
time, and get a different "name").

	Are the "records" different for fighters vs destroyers? That is: do you
have a base "ship" type which is extended for "TIE fighter" and "star
destroyer", with the service bays and "stack" having to handle either class
at any moment?

	There is no explanation of what you mean by "'C' option" -- program
written in the C language? Given the rest of the description, it could be
specifications for how the instructor will test the operation of your
program (ie: will feed it a test set expecting only 20 service bays --
while the program must be flexible enough to be run with a different number
of service bays based upon initialization value from the user; note that
Ada would actually permit you to run with lower bound -9, upper bound +10,
and still have 20 service bays).

	Are ships serviced in order of arrival (which would imply a queue, not
a stack). If in stack order, with two "stacks" I first thought a deque
structure -- fighters coming in at one end, and destroyers at the other
end, but that doesn't really work. Using a structure in which each type
builds in from the ends, and the facility is full when the two types meet
in the middle might work.

	The assignment sounds like an exercise in data structures and
algorithms -- so you should study how stacks and deques are handled; then
figure out how to modify such a structure to work for the two classes of
ships.

	A priority (ship class) ordered double-ended linked-list with a pool of
free-nodes would be my next candidate. That would allow processing each
class in queue order (by traversing the linked list to find the oldest
entry of the ship type and removing it) while not having to shift data.
(The free pool actually would represent the unused service bays).


	BTW: Your subject line references "time system", but nothing in your
post mentions how time is involved in this exercise. Does each received
ship get assigned a "repair time" (maybe a random generated value), which
controls how long it stays in a repair bay?


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

  parent reply	other threads:[~2019-09-16 16:02 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
2019-09-16 16:02 ` Dennis Lee Bieber [this message]
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