18.10.2014 Views

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A Text user <strong>in</strong>terface 323<br />

with Class_Board, Class_W<strong>in</strong>dow;<br />

use Class_Board, Class_W<strong>in</strong>dow;<br />

package Pack_Program is<br />

procedure Play;<br />

private<br />

Game : Board; --The board<br />

P_W<strong>in</strong>_Brd : P_W<strong>in</strong>dow; --W<strong>in</strong>dow to display OXO board <strong>in</strong><br />

P_W<strong>in</strong>_Bnr : P_W<strong>in</strong>dow; --W<strong>in</strong>dow to display Banner <strong>in</strong><br />

P_W<strong>in</strong>_R : P_W<strong>in</strong>dow; --W<strong>in</strong>dow to display commentary <strong>in</strong><br />

Player : Character; --Either 'X' or 'O'<br />

end Pack_Program;<br />

The private part of the package is as follows:<br />

with <strong>Ada</strong>.Integer_Text_Io,<br />

Class_Dialog, Class_Menu, Class_Input_Manager, Class_Menu_Title;<br />

use <strong>Ada</strong>.Integer_Text_Io,<br />

Class_Dialog, Class_Menu, Class_Input_Manager, Class_Menu_Title;<br />

package body Pack_Program is<br />

The procedure Play sets up the various w<strong>in</strong>dows used to display the game.<br />

procedure Play is<br />

beg<strong>in</strong><br />

W<strong>in</strong>dow_Prologue; --Setup w<strong>in</strong>dow system<br />

declare<br />

W<strong>in</strong>_Brd : aliased W<strong>in</strong>dow; --Board W<strong>in</strong>dow<br />

W<strong>in</strong>_R : aliased W<strong>in</strong>dow; --Result W<strong>in</strong>dow<br />

W<strong>in</strong>_Bnr : aliased W<strong>in</strong>dow; --title W<strong>in</strong>dow<br />

W<strong>in</strong>_Usr : aliased Dialog; --Input W<strong>in</strong>dow<br />

Ttt_Reset: aliased Menu; --Reset menu<br />

Ttt_Menu : Menu_Title; --Title menu<br />

The various w<strong>in</strong>dows on the screen are then <strong>in</strong>itialized to their fixed co-ord<strong>in</strong>ate positions.<br />

beg<strong>in</strong><br />

Framework( W<strong>in</strong>_Bnr, 1, 4, 52, 3 ); --Banner<br />

Framework( W<strong>in</strong>_Brd, 32, 8, 13, 9 ); --OXO board<br />

Framework( W<strong>in</strong>_R, 9, 14, 22, 3 ); --Results<br />

The menu bar sequence is then def<strong>in</strong>ed with the follow<strong>in</strong>g frameworks:<br />

Framework( Ttt_Reset,<br />

"X start", null, Reset_X'access,<br />

"O start", null, Reset_O'access );<br />

Framework( Ttt_Menu,<br />

"About", null, About'access,<br />

"Reset", Ttt_Reset'Unchecked_Access, null );<br />

Follow<strong>in</strong>g the <strong>in</strong>itialization of global variables the writ<strong>in</strong>g of various <strong>in</strong>troductory messages is performed:<br />

© M A Smith - May not be reproduced without permission

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!