[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/game round.h round.cpp
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot/game round.h round.cpp |
Date: |
Mon, 26 Dec 2005 15:52:48 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Branch:
Changes by: Antoine Fraboulet <address@hidden> 05/12/26 15:52:48
Modified files:
game : round.h round.cpp
Log message:
- adding getWord and toString methods
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/round.h.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/round.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: eliot/game/round.cpp
diff -u eliot/game/round.cpp:1.6 eliot/game/round.cpp:1.7
--- eliot/game/round.cpp:1.6 Sat Nov 5 13:56:59 2005
+++ eliot/game/round.cpp Mon Dec 26 15:52:48 2005
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
+#include <string>
#include "tile.h"
#include "round.h"
@@ -140,3 +141,40 @@
m_tileOrigin.pop_back();
}
+string Round::getWord() const
+{
+ char c;
+ std::string s;
+
+ for (int i = 0; i < getWordLen(); i++)
+ {
+ c = getTile(i).toChar();
+ if (isJoker(i))
+ c = tolower(c);
+ s += c;
+ }
+ return s;
+}
+
+string Round::toString() const
+{
+ char buff[5];
+ string rs(" ");
+
+ if (getWord().size() > 0)
+ {
+ rs = getWord();
+ rs += string(16 - getWord().size(), ' ');
+ rs += getBonus() ? '*' : ' ';
+ sprintf(buff,"%4d",getPoints());
+ rs += buff;
+ rs += " " + getCoord().toString();
+ }
+
+ return rs;
+}
+
+/// Local Variables:
+/// mode: hs-minor
+/// c-basic-offset: 4
+/// End:
Index: eliot/game/round.h
diff -u eliot/game/round.h:1.9 eliot/game/round.h:1.10
--- eliot/game/round.h:1.9 Sat Nov 5 13:56:59 2005
+++ eliot/game/round.h Mon Dec 26 15:52:48 2005
@@ -70,6 +70,8 @@
bool isJoker (int iIndex) const;
bool isPlayedFromRack(int iIndex) const;
const Tile& getTile (int iIndex) const;
+
+ string getWord() const;
int getWordLen() const;
int getPoints() const { return m_points; }
int getBonus() const { return m_bonus; }
@@ -80,6 +82,8 @@
const Coord& getCoord() const { return m_coord; }
Coord& accessCoord() { return m_coord; }
+ std::string toString() const;
+
private:
vector<Tile> m_word;
vector<char> m_tileOrigin;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/game round.h round.cpp,
eliot-dev <=