From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 16 Sep 2019 11:02:44 -0500 From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: Ada stacks and the time system Date: Mon, 16 Sep 2019 12:02:44 -0400 Organization: IISS Elusive Unicorn Message-ID: <7iavne5pj826nf5felshia363dl778k9am@4ax.com> References: <8c293e09-fc74-45a4-b109-cd4041a4a311@googlegroups.com> User-Agent: ForteAgent/8.00.32.1272 X-No-Archive: YES MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-x5URsvjCqZUm/aIpN+V+yZ3DZY9GEbF1YRpj/7EtdycW7xCXNUdpd42wamL9ilraiLtmJCtsc6JCu3D!uC+kTH8au0oHwPWyIyNng8sbj7q0keYqY1M435TlgvYBsQ1JQWUM+vVCSDC87l3I6KvGV8Rc X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 5140 Xref: reader01.eternal-september.org comp.lang.ada:57159 Date: 2019-09-16T12:02:44-04:00 List-Id: On Sun, 15 Sep 2019 23:39:53 -0700 (PDT), sandeep parajuli 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/