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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,aa7f494bf30adbc7 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: [newbie] simple(?) data structures References: <2j1e30Fsrg8vU1@uni-berlin.de> In-Reply-To: <2j1e30Fsrg8vU1@uni-berlin.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <0gNyc.3025$Wr.295@newsread1.news.pas.earthlink.net> Date: Sun, 13 Jun 2004 00:31:56 GMT NNTP-Posting-Host: 63.184.32.162 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1087086716 63.184.32.162 (Sat, 12 Jun 2004 17:31:56 PDT) NNTP-Posting-Date: Sat, 12 Jun 2004 17:31:56 PDT Xref: g2news1.google.com comp.lang.ada:1433 Date: 2004-06-13T00:31:56+00:00 List-Id: Roland Illig wrote: > > I'm doing my first steps with Ada. I tried to model a Go board and > failed. In Java/C++, I would do it like this: How one would do it in a C-based language is almost certainly irrelevant to a good implementation in Ada. If you let us know what you did in Ada, and how you failed, we could give you more guidance, especially if this is homework. Just out of curiosity, what are calls such as Go_Board (-10) or getStone (-10, -7) supposed to do? Your specification does not disallow them. I would probably do something along the lines of package Go is type Intersection_Content is (Empty, Black, White); type Board_Size is (Nine, Thirteen, Nineteen); type Intersection_Num is range 1 .. 19; type Board is limited private; Invalid_Board : exception; Invalid_Intersection : exception; procedure Create (Go_Board : out Board; Size : in Board_Size); function Size (Go_Board : Board) return Board_Size; -- Raises Invalid_Board if Go_Board has not been created. function Contents (Go_Board : Board; Row : Intersection_Num; Column : Intersection_Num) return Intersection_Content; -- Raises Invalid_Board if Go_Board has not been created. -- Raises Invalid_Intersection if Row or Column are not valid for -- Size (Go_Board). -- Possibly other operations, such as Set. private -- Go ... end Go; -- Jeff Carter "Ditto, you provincial putz?" Blazing Saddles 86