⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deck.cpp

📁 含有uml的多个实例及实例的java源码。
💻 CPP
字号:
// {{{RME classifier 'Logical View::CardDefinitions::Deck'#if defined( PRAGMA ) && ! defined( PRAGMA_IMPLEMENTED )#pragma implementation "Deck.h"#endif#include <RTSystem/CardGameComponent.h>#include <Deck.h>#include <Card.h>// {{{RME tool 'OT::Cpp' property 'ImplementationPreface'// {{{USR// }}}USR// }}}RMEstatic void rtg_Deck_init( const RTObject_class * type, Deck * target ){	(void)new( target ) Deck;}static void rtg_Deck_copy( const RTObject_class * type, Deck * target, const Deck * source ){	(void)new( target ) Deck( *source );}static void rtg_Deck_destroy( const RTObject_class * type, Deck * target ){	target->~Deck();}const RTObject_class RTType_Deck ={	(const RTObject_class *)0  , (RTSuperAccessFunction)0  , "Deck"  , (RTVersionId)0  , (RTFieldOffset)sizeof( Deck )  , (RTInitFunction)rtg_Deck_init  , (RTCopyFunction)rtg_Deck_copy#if OBJECT_DECODE  , RTstruct_decode#endif#if OBJECT_ENCODE  , RTstruct_encode#endif  , (RTDestroyFunction)rtg_Deck_destroy  , 2  , Deck::rtg_Deck_fields};// {{{RME tool 'OT::Cpp' property 'GenerateDefaultConstructor'Deck::Deck( void )	: _top( 0 ){}// }}}RME// {{{RME tool 'OT::Cpp' property 'GenerateDestructor'Deck::~Deck( void ){}// }}}RME// {{{RME tool 'OT::Cpp' property 'GenerateCopyConstructor'Deck::Deck( const Deck & rtg_arg )	: _top( rtg_arg._top )	, _cards( rtg_arg._cards ){}// }}}RME// {{{RME tool 'OT::Cpp' property 'GenerateAssignmentOperator'Deck & Deck::operator=( const Deck & rtg_arg ){	if( this != &rtg_arg )	{		_top = rtg_arg._top;		_cards = rtg_arg._cards;	}	return *this;}// }}}RME// {{{RME operation 'Deck(int)'Deck::Deck( int initial_size )	// {{{RME tool 'OT::Cpp' property 'ConstructorInitializer'	// {{{USR	: _cards(initial_size), _top(0)	// }}}USR	// }}}RME{	// {{{USR	// }}}USR}// }}}RME// {{{RME operation 'size()'int Deck::size( void ){	// {{{USR	return _cards.size();	// }}}USR}// }}}RME// {{{RME operation 'init()'void Deck::init( void ){	// {{{USR	int suit = 1;	for( int start = 0 ; start < size() ; start++ )	{		_cards[ start ].rank = (start % 13) + 1;		_cards[ start ].suit = suit;		if( _cards[ start ].rank == 13 )			suit++;	}	_top = 0;	// }}}USR}// }}}RME// {{{RME operation 'get(Card &)'int Deck::get( Card & card ){	// {{{USR	if( _top == size() )		return 0;	card = _cards[ _top++ ];	return 1;	// }}}USR}// }}}RME// {{{RME operation 'shuffle()'void Deck::shuffle( void ){	// {{{USR	// shuffle any size of card deck	int  swap = 150;	int  index1, index2;	Card temp;	int  split = size() / 2;	init();	srand( (unsigned)time( NULL ) ); 	for( int i = 0 ; i < swap ; i++ )	{		// pick two random cards		index1 = rand() % split;		index2 = rand() % (split * 2);		// swap cards		temp             = _cards[ index1 ];		_cards[ index1 ] = _cards[ index2 ];		_cards[ index2 ] = temp;	} 	// }}}USR}// }}}RMEconst RTFieldDescriptor Deck::rtg_Deck_fields[] ={	// {{{RME classAttribute '_top'	{		"_top"	  , RTOffsetOf( Deck, _top )		// {{{RME tool 'OT::CppTargetRTS' property 'TypeDescriptor'	  , &RTType_int		// }}}RME		// {{{RME tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'	  , (const RTTypeModifier *)0		// }}}RME	}	// }}}RME	// {{{RME associationEnd '_cards'  , {		"_cards"	  , RTOffsetOf( Deck, _cards )		// {{{RME tool 'OT::CppTargetRTS' property 'TypeDescriptor'	  , &RTType_CardList		// }}}RME		// {{{RME tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'	  , (const RTTypeModifier *)0		// }}}RME	}	// }}}RME};#if OBJECT_DECODERTTypeInstaller rtg_Deck_installer( RTType_Deck );#endif// {{{RME tool 'OT::Cpp' property 'ImplementationEnding'// {{{USR// }}}USR// }}}RME// }}}RME

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -