首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于UML的有关问题!

2012-03-09 
关于UML的问题!急。第一次听说UML,就是两天前,要给一段程序画个UML出来不会啊急哪位大哥帮忙画一下啊会的人

关于UML的问题!急。
第一次听说UML,就是两天前,要给一段程序画个UML出来  
不会啊     急  
哪位大哥帮忙画一下啊       会的人应该不难的     因为程序不复杂
我的email:zhougz2000@hotmail.com     加我QQ也行:365640642     谢谢啦     本人比较穷     分不多     多包涵


#include   <iostream.h>
#include   <stdlib.h>
#include   <time.h>

#   define   LocationEmpty_Code   1
#   define   LocationTreasure_Code   2
#   define   LocationTried_Code   3
#   define   LocationReset_Code   4


class   Treasure
{
protected:
                int   grid;                                            
        int   **Map;
int   Dig_X_Coord;
int   Dig_Y_Coord;
int   Difficulty;                  
int   TotalMoves;
int   MovesSoFar;
int   Treasure_X_Coord;
int   Treasure_Y_Coord;
bool   PlayerWon;
bool   PlayerDead;
       
public:
      Treasure(void);
      int   getGrid();
      int   printMap();
      int   readCoord();
      void   setGrid(int   grid);
              void   winMessage();
      void   Dig();
              void   noTreasureMessage();
      void   showmenu();
      void   initMap(int   gridSize);
     
};

Treasure::Treasure(void)
{
srand(time(0));
grid   =   7;
PlayerWon=false;
PlayerDead=false;
Difficulty=10;
TotalMoves=Difficulty;
MovesSoFar     =0;
initMap(grid);
}

void   Treasure::initMap(int   gridSize)
{
//   sets   the   size   of   the   map
grid   =   gridSize;
Map   =   new   int*[grid];
        //cout   < <   "setting   size   of   grid   to   be   :   \n "   < <   grid;
for(int   x   =   0;   x   <   grid;   x++)
{
Map[x]   =   new   int[grid];
}

for(int   y   =   0;   y   <   grid;   y++)
{
for(int   x   =   0;   x   <   grid;   x++)
{
Map[x][y]   =   LocationEmpty_Code;
}
}
Treasure_X_Coord   =   (int)(rand()%grid);  
Treasure_Y_Coord   =   (int)(rand()%grid);
Map[Treasure_X_Coord][Treasure_Y_Coord]   =   LocationTreasure_Code;
Dig_X_Coord=LocationReset_Code;
Dig_Y_Coord=LocationReset_Code;
}

int   Treasure::readCoord()
{
        return   1;
}


int   Treasure::getGrid()
{
        return   grid;
}


void   Treasure::winMessage()
{
        //   thw   win   message   if   the   treasure   is   found    


cout   < < "\n\nWell   done!   You   win   a   2-day   holiday   into   The   Other   Matrix. " < <   endl;
}

               

void   Treasure::Dig()
{while(!PlayerWon   &&   !PlayerDead)
{      
//   displays   the   map
printMap();
       
cout < < "\nEnter   X   co-ordinate   to   Dig: " < <endl;
cin   > >   Dig_X_Coord;  
               
cout < < "\nEnter   Y   co-ordinate   to   Dig: " < <endl;
cin> > Dig_Y_Coord;  
   
if(Dig_X_Coord==Treasure_X_Coord   &&   Dig_Y_Coord==Treasure_Y_Coord)
{
Map[Treasure_X_Coord][Treasure_Y_Coord]   =   LocationTreasure_Code;
printMap();                        
cout   < <   "\n\nYou   found   the   treasure   in   "  
< <   (MovesSoFar+1)   < < "   move(s). "   < <   endl;                                                                
PlayerWon   =   true;
winMessage();
}
       
else

{                            
MovesSoFar++;                        
Map[Dig_X_Coord][Dig_Y_Coord]   =   LocationTried_Code;                                                    
noTreasureMessage();
if(MovesSoFar   ==   TotalMoves)
{
PlayerDead=true;            
cout < < "\n\nBad   luck.   Pirates   made   you   walk   the   plank. " < <endl;
}                        
                        else  
{
cout < < "\nYou   have   "   < <   (TotalMoves-MovesSoFar)   < <   "   move(s)   until   the   pirates   arrive. " < <endl;
}          
}                                                                                                                                                  
}
}

int   Treasure::printMap()
{              
                cout   < < "\n\t ";


        for(int   x=0;   x <grid;   x++)
                cout   < < "\t "   < <   x;
               
                for(int   y=0;   y <grid;   y++)
                {
                    cout   < < "\n\t "   < <   y;  
                    for(int   x=0;   x <grid;   x++)
                    {
                      if(Map[x][y]   ==   LocationEmpty_Code)
                      cout   < < "\t? ";
else   if(Map[x][y]   ==   LocationTreasure_Code)
cout   < < "\t? ";
else   if(Map[x][y]   ==   LocationTried_Code)
cout   < < "\t# ";
                    }
                }
return   1;
}

void   Treasure::noTreasureMessage()
{
            int   messageflag   =   (int)(rand()%2   +   0.5);              
            switch(messageflag)
            {
                  case   0:   cout   < < "\nOh   look,   a   hole   with   nothing   in   it. " < <   endl;break;
                  case   1:   cout   < < "\nNo   treasure   here. " < <   endl;break;
                  case   2:   cout   < < "\nThis   is   boring. " < <   endl;break;
            }            
      }

void   Treasure::showmenu()
{
cout < < "   _____________________________________________________________________________\n "
< < "|                                                                 TREASURE   HUNT                                                             |\n "
< < "|___________________________________________________________________________|\n " < <endl;

cout < < "Somewhere   buried   in   a   field   is   a   treasure   chest.\n "
< < "Find   the   treasure   before   the   pirates   arrives.\n "
< < "Symbols:   '? '=Dig   Site,   '# '=tried,   '* '=treasure " < <endl;            


               
}

class   GameLevel   :   public   Treasure
{
private:

public:
GameLevel();
void   setGameLevel(int   level);
void   showGameLevel();
int   selectGameLevel(int   level);

};

GameLevel::GameLevel()
{

}

void   GameLevel::showGameLevel()
{
cout   < < "\n ";
cout   < < "   _____________________________________________________________________________\n ";
cout   < < "|                                                         PLEASE   SELECT                                                                     |\n ";
cout   < < "|___________________________________________________________________________|\n ";
cout   < < "|                                                         1           VERY   HARD                                                                 |\n ";
cout   < < "|                                                                                                                                                       |\n ";
cout   < < "|                                                         2           HARD                                                                           |\n ";
cout   < < "|                                                                                                                                                       |\n ";
cout   < < "|                                                         3           NORMAL                                                                       |\n ";


cout   < < "|                                                                                                                                                       |\n ";
cout   < < "|                                                         4           EASY                                                                           |\n ";
cout   < < "|                                                                                                                                                       |\n ";
cout   < < "|                                                         5           VERY   EASY                                                                 |\n ";
cout   < < "|___________________________________________________________________________|\n " < <endl;


}

int   GameLevel::selectGameLevel(int   level)
{
int   choice;

do{showGameLevel();
cin> > choice;
switch   (choice)
{
        case   1   :   setGameLevel(1);
  cout   < <   "setting   size   of   grid   to   be   :   "   < <   grid;break;
        case   2   :   setGameLevel(2);
  cout   < <   "setting   size   of   grid   to   be   :   "   < <   grid;break;  
case   3   :   setGameLevel(3);
  cout   < <   "setting   size   of   grid   to   be   :   "   < <   grid;break;
case   4   :   setGameLevel(4);
  cout   < <   "setting   size   of   grid   to   be   :   "   < <   grid;break;
case   5   :   setGameLevel(5);
  cout   < <   "setting   size   of   grid   to   be   :   "   < <   grid;break;


default:   cout < < "\n\tInvalid   entry\n " < <endl;

}
}while   (choice   >   5);

return   0   ;

}


void   GameLevel::setGameLevel(int   level)
{
int   grid;
if   (level   ==   1)
{grid   =   8;
initMap(grid);
}
else   if   (level   ==   2)
{grid   =   6;
initMap(grid);
}
else   if   (level   ==   3)
{grid   =   5;
initMap(grid);
}
else   if   (level   ==   4)
{grid   =   3;
initMap(grid);
}
else   if   (level   ==   5)
{grid   =   2;
initMap(grid);
}
TotalMoves=   grid;
}


void   main(void)
{
GameLevel   gamelevel;
int   level=0;
int   grid;
//cout   < <   "PLEASE   ENTER   GRID   SIZE:   ";
//cin   > >   grid;
//game.initMap(grid);  
gamelevel.showmenu();
gamelevel.selectGameLevel(level);
gamelevel.Dig();
system( "pause ");

}


[解决办法]
这个太长了。。。 看不懂
uml我也不会
[解决办法]
推荐个forum:http://bbs.umltec.com/index.asp?boardid=2
[解决办法]
参考uml建模设计
很简单滴 不用担心 偶也是就2周时间就搞定了
[解决办法]
竟然什么注释都没有,想帮都没办法了。
[解决办法]
------------------------------------------------------你的代码也太长了

Trufun Kant for C++为C++系统分析员、C++设计师、C++程序员量身定做。

产品情况:http://www.trufun.net/products/product_kantc.htm


"嵌入eclipse CDT的类图 "支持的功能如下:

新建C++类图
"C/C++ Projects "视图到类图的拖放:支持将C++元素从 "C/C++ Projects "视图拖放到类图,并显示到类图。可拖放的C++元素包括C++类 。
C++项目的反向工程:批处理操作。自动生成C++项目所有选择包的类图。每个包1个类图。同时提供清理操作,可以清除生成的所有类图文件。
包的自动生成类图:可以自动生成包下选择类型的继承关系、关联关系图,并自动布局。
类的自动生成类图:可以自动生成类的继承关系图。
框图和源码的交互操作:通过框图操作,生成包、类、接口、枚举、字段、方法、继承、实现;通过C++编辑器修改源码并保存时,框图自动同步。框图打开时,自动同步C++源码。
其他功能:显示选项,复制图像,打印,导出图像,自动布局,框图元素到C++元素的导航。
[解决办法]
有关UML的问题可以到下面的群里面讨论,专业的uml讨论群哦11090149
[解决办法]
找个工具生成一下吧。
[解决办法]
学习
[解决办法]
把关系理清楚 画出来很好的了 就像打草稿一样 可以修改 一般在具体实现前画这个好
[解决办法]
UML工具反向工程一下不就行了.

热点排行