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,FREEMAIL_FROM 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!news.glorb.com!cyclone1.gnilink.net!gnilink.net!wn14feed!worldnet.att.net!attbi_s04.POSTED!53ab2750!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: <2j1e30Fsrg8vU1@uni-berlin.de> Subject: Re: [newbie] simple(?) data structures X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: NNTP-Posting-Host: 24.21.42.251 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s04 1087101974 24.21.42.251 (Sun, 13 Jun 2004 04:46:14 GMT) NNTP-Posting-Date: Sun, 13 Jun 2004 04:46:14 GMT Organization: Comcast Online Date: Sun, 13 Jun 2004 04:46:14 GMT Xref: g2news1.google.com comp.lang.ada:1438 Date: 2004-06-13T04:46:14+00:00 List-Id: To me this looks like a simple dynamically sized structure. Here is the package spec I might use. Note that in your example you set the x and y sizes to the same. For my spec I force them to the same size in the Go_Board definition. package Go is type Stone is ( Empty, Black, White ); Max_Size : constant := 10_000; type Go_Range is range 1 .. Max_Size; type Go_Board( Go_Size : Go_Range ) is private; function Get_Stone( board : Go_Board; x, y : Go_Range ) return Stone; function Get_Size( board : Go_Board ) return Go_Range; private type Go_Cells is array( Go_Range range <>, Go_Range range <> ) of Stone; type Go_Board( Go_Size : Go_Range ) is record data : Go_Cells( 1 .. Go_Size, 1 .. Go_Size ); end record; end Go; Steve (The Duck) "Roland Illig" wrote in message news:2j1e30Fsrg8vU1@uni-berlin.de... > Hi, > > 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: > > enum Stone { Empty, Black, White }; > > class Go_Board { > private Stone[][] data; > > public Go_Board(int size) { > data = new Stone[size][size]; > } > public int getWidth() { > return data[0].length; > } > public int getHeight() { > return data.length; > } > public Stone getStone(int x, int y) { > return data[y][x]; > } > } > /* EOF */ > > How can I do this in Ada? I already tried something with packages and > generics, but that did not look nice. But I want it to look nice and Adaish. > > Roland