diff options
author | xue <> | 2005-12-26 15:55:46 +0000 |
---|---|---|
committer | xue <> | 2005-12-26 15:55:46 +0000 |
commit | 00286fc77d56f60b67148716722dc874723e8682 (patch) | |
tree | 2ba7020c7a69ad75a0dbce2f4b74f78a2a4a44a2 /demos/quickstart/protected/pages/chap3 | |
parent | 9be8859d92e4bbec2462e82457d014f0a0d720db (diff) |
Diffstat (limited to 'demos/quickstart/protected/pages/chap3')
-rw-r--r-- | demos/quickstart/protected/pages/chap3/Hangman.page | 16 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/Hangman/Home.page | 74 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/Hangman/Home.php | 135 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/Hangman/config.xml | 5 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/Hangman/words.txt | 27 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld.page | 26 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/Home.page | 18 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/Home.php | 11 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/config.xml | 5 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif | bin | 5557 -> 0 bytes | |||
-rw-r--r-- | demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd | bin | 143360 -> 0 bytes |
11 files changed, 0 insertions, 317 deletions
diff --git a/demos/quickstart/protected/pages/chap3/Hangman.page b/demos/quickstart/protected/pages/chap3/Hangman.page deleted file mode 100644 index b623bad4..00000000 --- a/demos/quickstart/protected/pages/chap3/Hangman.page +++ /dev/null @@ -1,16 +0,0 @@ -<com:TContent ID="body" >
-<h1>Sample: Hangman Game</h1>
-<p>
-Having seen the simple "Hello World" application, we now build a more complex application called "Hangman Game". In this game, the player is asked to guess a word, a letter at a time. If he guesses a letter right, the letter will be shown in the word. The player can continue to guess as long as the number of his misses is within a prespecified bound. The player wins the game if he finds out the word within the miss bound, or he loses.
-</p>
-<p>
-To facilitate the building of this game, we show the state transition diagram of the gaming process in the following,
-</p>
-<p>
-To be continued...
-</p>
-<div class="runbar">
-<a href="?page=chap3.Hangman.Home" target="_blank">Run Sample</a>
-<a href="?page=ViewSource&path=/chap3/Hangman/Home.php" target="_blank">View Source</a>
-</div>
-</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/Hangman/Home.page b/demos/quickstart/protected/pages/chap3/Hangman/Home.page deleted file mode 100644 index 1cc409d3..00000000 --- a/demos/quickstart/protected/pages/chap3/Hangman/Home.page +++ /dev/null @@ -1,74 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Hangman Game</title>
-</head>
-
-<body>
-<com:TForm>
-<h1>Hangman Game</h1>
-
-<com:TPanel ID="IntroPanel">
-<p>This is the game of Hangman. You must guess a word, a letter at a time.
-If you make too many mistakes, you lose the game!</p>
-<com:TRadioButton ID="EasyLevel" GroupName="level" Text="Easy game; you are allowed 10 misses." /><br/>
-<com:TRadioButton ID="MediumLevel" GroupName="level" Text="Medium game; you are allowed 5 misses." /><br/>
-<com:TRadioButton ID="HardLevel" GroupName="level" Text="Hard game; you are only allowed 3 misses." /><br/>
-<com:TButton Text="Play!" Click="selectLevel" />
-<com:TLabel ID="LevelError" Text="You must choose a difficulty level!" ForeColor="red" Visible="false" />
-</com:TPanel>
-
-<com:TPanel ID="GuessPanel" Visible="false">
-<h2>Please make a guess</h2>
-<h3 style="letter-spacing: 4px;"><%= $this->Page->GuessWord %></h3>
-<p>You have made <%=$this->Page->Misses %> bad guesses
-out of a maximum of <%= $this->Page->Level %>.</p>
-<p>Guess:
-<com:TLinkButton ID="GuessA" Text="A" Click="guessWord" />
-<com:TLinkButton ID="GuessB" Text="B" Click="guessWord" />
-<com:TLinkButton ID="GuessC" Text="C" Click="guessWord" />
-<com:TLinkButton ID="GuessD" Text="D" Click="guessWord" />
-<com:TLinkButton ID="GuessE" Text="E" Click="guessWord" />
-<com:TLinkButton ID="GuessF" Text="F" Click="guessWord" />
-<com:TLinkButton ID="GuessG" Text="G" Click="guessWord" />
-<com:TLinkButton ID="GuessH" Text="H" Click="guessWord" />
-<com:TLinkButton ID="GuessI" Text="I" Click="guessWord" />
-<com:TLinkButton ID="GuessJ" Text="J" Click="guessWord" />
-<com:TLinkButton ID="GuessK" Text="K" Click="guessWord" />
-<com:TLinkButton ID="GuessL" Text="L" Click="guessWord" />
-<com:TLinkButton ID="GuessM" Text="M" Click="guessWord" />
-<com:TLinkButton ID="GuessN" Text="N" Click="guessWord" />
-<com:TLinkButton ID="GuessO" Text="O" Click="guessWord" />
-<com:TLinkButton ID="GuessP" Text="P" Click="guessWord" />
-<com:TLinkButton ID="GuessQ" Text="Q" Click="guessWord" />
-<com:TLinkButton ID="GuessR" Text="R" Click="guessWord" />
-<com:TLinkButton ID="GuessS" Text="S" Click="guessWord" />
-<com:TLinkButton ID="GuessT" Text="T" Click="guessWord" />
-<com:TLinkButton ID="GuessU" Text="U" Click="guessWord" />
-<com:TLinkButton ID="GuessV" Text="V" Click="guessWord" />
-<com:TLinkButton ID="GuessW" Text="W" Click="guessWord" />
-<com:TLinkButton ID="GuessX" Text="X" Click="guessWord" />
-<com:TLinkButton ID="GuessY" Text="Y" Click="guessWord" />
-<com:TLinkButton ID="GuessZ" Text="Z" Click="guessWord" />
-</p>
-<p><com:TLinkButton Text="Give up?" Click="giveUp" /></p>
-</com:TPanel>
-
-<com:TPanel ID="WinPanel" Visible="false">
-<h2>You Win!</h2>
-<p>The word was: <%= $this->Page->Word %>.</p>
-<p><com:TLinkButton Text="Start Again" Click="startAgain" /></p>
-</com:TPanel>
-
-<com:TPanel ID="LosePanel" Visible="false">
-<h2>You Lose!</h2>
-<p>The word was: <%= $this->Page->Word %>.</p>
-<p><com:TLinkButton Text="Start Again" Click="startAgain" /></p>
-</com:TPanel>
-</com:TForm>
-
-</body>
-</html>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/Hangman/Home.php b/demos/quickstart/protected/pages/chap3/Hangman/Home.php deleted file mode 100644 index 93028573..00000000 --- a/demos/quickstart/protected/pages/chap3/Hangman/Home.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php
-
-class Home extends TPage
-{
- const EASY_LEVEL=10;
- const MEDIUM_LEVEL=5;
- const HARD_LEVEL=3;
-
- public function selectLevel($sender,$param)
- {
- if($this->EasyLevel->Checked)
- $this->Level=self::EASY_LEVEL;
- else if($this->MediumLevel->Checked)
- $this->Level=self::MEDIUM_LEVEL;
- else if($this->HardLevel->Checked)
- $this->Level=self::HARD_LEVEL;
- else
- {
- $this->LevelError->Visible=true;
- return;
- }
-
- $this->Word=$this->generateWord();
- $this->GuessWord=str_repeat('_',strlen($this->Word));
- $this->Misses=0;
- $this->showPanel('GuessPanel');
- }
-
- public function guessWord($sender,$param)
- {
- $sender->Enabled=false;
- $letter=$sender->Text;
- $word=$this->Word;
- $guessWord=$this->GuessWord;
- $pos=0;
- $success=false;
- while(($pos=strpos($word,$letter,$pos))!==false)
- {
- $guessWord[$pos]=$letter;
- $success=true;
- $pos++;
- }
- if($success)
- {
- $this->GuessWord=$guessWord;
- if($guessWord===$word)
- $this->showPanel('WinPanel');
- }
- else
- {
- $this->Misses++;
- if($this->Misses>=$this->Level)
- $this->giveUp(null,null);
- }
- }
-
- public function giveUp($sender,$param)
- {
- $this->showPanel('LosePanel');
- }
-
- public function startAgain($sender,$param)
- {
- $this->showPanel('IntroPanel');
- $this->LevelError->Visible=false;
- for($letter=65;$letter<=90;++$letter)
- {
- $guessLetter='Guess'.chr($letter);
- $this->$guessLetter->Enabled=true;
- }
- }
-
- protected function generateWord()
- {
- $wordFile=dirname(__FILE__).'/words.txt';
- $words=preg_split("/[\s,]+/",file_get_contents($wordFile));
- do
- {
- $i=rand(0,count($words)-1);
- $word=$words[$i];
- } while(strlen($word)<5 || !preg_match('/^[a-z]*$/i',$word));
- return strtoupper($word);
- }
-
- protected function showPanel($panelID)
- {
- $this->IntroPanel->Visible=false;
- $this->GuessPanel->Visible=false;
- $this->WinPanel->Visible=false;
- $this->LosePanel->Visible=false;
- $this->$panelID->Visible=true;
- }
-
- public function setLevel($value)
- {
- $this->setViewState('Level',$value,0);
- }
-
- public function getLevel()
- {
- return $this->getViewState('Level',0);
- }
-
- public function setWord($value)
- {
- $this->setViewState('Word',$value,'');
- }
-
- public function getWord()
- {
- return $this->getViewState('Word','');
- }
-
- public function getGuessWord()
- {
- return $this->getViewState('GuessWord','');
- }
-
- public function setGuessWord($value)
- {
- $this->setViewState('GuessWord',$value,'');
- }
-
- public function setMisses($value)
- {
- $this->setViewState('Misses',$value,0);
- }
-
- public function getMisses()
- {
- return $this->getViewState('Misses',0);
- }
-}
-
-?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/Hangman/config.xml b/demos/quickstart/protected/pages/chap3/Hangman/config.xml deleted file mode 100644 index 67056f9d..00000000 --- a/demos/quickstart/protected/pages/chap3/Hangman/config.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-
-<configuration>
- <pages MasterClass="" />
-</configuration>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/Hangman/words.txt b/demos/quickstart/protected/pages/chap3/Hangman/words.txt deleted file mode 100644 index 80814580..00000000 --- a/demos/quickstart/protected/pages/chap3/Hangman/words.txt +++ /dev/null @@ -1,27 +0,0 @@ -This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-PRADO is an event-driven and component-based framework
-for Web application development in PHP 5.
-
-Components following the PRADO protocol are highly
-configurable and reusable. Properties defining
-the basic features of a component can be configured
-in specifications, templates or code.
-New components can be developed by either inheriting
-an existing component class or composing several
-components together. The work of using a component
-amounts to placing the component tag on the page template,
-configuring component properties, and writing handler
-functions to respond to component events.
-
-PRADO shares many similarities with ASP.NET and other
-RAD tools for Windows GUI development, such as Borland Delphi.
-In particular, it supports event-driven programming,
-viewstate maintenance, javascript, template, form validations, etc.
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld.page b/demos/quickstart/protected/pages/chap3/HelloWorld.page deleted file mode 100644 index a39aed33..00000000 --- a/demos/quickstart/protected/pages/chap3/HelloWorld.page +++ /dev/null @@ -1,26 +0,0 @@ -<com:TContent ID="body" >
-<h1>Sample: Hello World</h1>
-<p>
-"Hello World" is the simplest <i>interactive</i> PRADO application that you can build. It displays to end-users a page with a submit button whose caption is <i>Click Me</i>. When the user clicks on the button, the button changes the caption to <i>Hello World</i>.
-</p>
-<p>
-There are many approaches that can achieve the above goal. One can submit the page to the server, examine the POST variable, and generate a new page with the button caption updated. Or one can simply use JavaScript to update the button caption upon its <i>onclick</i> event.
-</p>
-<p>
-PRADO promotes component-based and event-driven Web programming. The button is represented by a <i>TButton</i> object. It encapsulates the button caption as the <i>Text</i> property and associates the user button click action with a server-side <i>Click</i> event. Therefore, the "Hello World" task can be handled intuitively and easily. One simply needs to attach a function to the button's <i>Click</i> event. Within the function, the button's <i>Text</i> property is modified as "Hello World". The following diagram shows the above sequence,
-</p>
-<img src="<%~HelloWorld/sequence.gif%>" />
-<p>
-The code that a developer needs to write is merely the following event handler function, where <code>$sender</code> refers to the button object.
-</p>
-<pre class="source">
-public function buttonClicked($sender,$param)
-{
- $sender->Text="Hello World";
-}
-</pre>
-<div class="runbar">
-<a href="?page=chap3.HelloWorld.Home" target="_blank">Run Sample</a>
-<a href="?page=ViewSource&path=/chap3/HelloWorld/Home.php" target="_blank">View Source</a>
-</div>
-</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/Home.page b/demos/quickstart/protected/pages/chap3/HelloWorld/Home.page deleted file mode 100644 index 158255cb..00000000 --- a/demos/quickstart/protected/pages/chap3/HelloWorld/Home.page +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Hello World</title>
-</head>
-
-<body>
-
-<com:TForm>
-<com:TButton Text="Click Me" Click="buttonClicked" />
-</com:TForm>
-
-</body>
-
-</html>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/Home.php b/demos/quickstart/protected/pages/chap3/HelloWorld/Home.php deleted file mode 100644 index b1a7f991..00000000 --- a/demos/quickstart/protected/pages/chap3/HelloWorld/Home.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $sender->Text="Hello World";
- }
-}
-
-?>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/config.xml b/demos/quickstart/protected/pages/chap3/HelloWorld/config.xml deleted file mode 100644 index 67056f9d..00000000 --- a/demos/quickstart/protected/pages/chap3/HelloWorld/config.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-
-<configuration>
- <pages MasterClass="" />
-</configuration>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif Binary files differdeleted file mode 100644 index a1e51200..00000000 --- a/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.gif +++ /dev/null diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd b/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd Binary files differdeleted file mode 100644 index e8c2f5a7..00000000 --- a/demos/quickstart/protected/pages/chap3/HelloWorld/sequence.vsd +++ /dev/null |