main.m文件:
#import <Foundation/Foundation.h>
#import "hearts.h" #import "spade.h"
#import "wintersweet.h"
#import "diamonds.h" #import "stdio.h"
#import "string.h"
int main(int argc, const char * argv[])
{
spade *m1=[spade alloc];
hearts *m2=[hearts alloc];
wintersweet *m3=[wintersweet alloc];
diamonds *m4=[diamonds alloc];
[m1 assignmentone];
[m2 assignmenttwo];
[m3 assignmentthree];
[m4 assignmentfour];
for(int i=0;i<13;i++)
{
printf("%s %s %d ",p1[i]->color,p1[i]->number,p1[i]->bigorsmall);
}
for(int i=0;i<13;i++)
{
printf("%s %s %d ",p2[i]->color,p2[i]->number,p2[i]->bigorsmall);
}
for(int i=0;i<13;i++)
{
printf("%s %s %d ",p3[i]->color,p3[i]->number,p3[i]->bigorsmall);
}
for(int i=0;i<13;i++)
{
printf("%s %s %d ",p4[i]->color,p4[i]->number,p4[i]->bigorsmall);
}
return 0;
}
diamonds.h文件:
#import <Foundation/Foundation.h>
@interface diamonds : NSObject
{
@public char color[10];
int bigorsmall; char number[3];
}
-(void)assignmentfour;
@end
diamonds * p4[13];
diamonds.m文件:
#import "diamonds.h"
#import "string.h"
#import "stdio.h"
@implementation diamonds
-(void)assignmentfour;
{
int i=0;
for(;i<13;i++)
{
p4[i]=[diamonds alloc];
p4[i]->bigorsmall=i+1;
strcpy(p4[i]->color, "diamonds");
}
for(i=0;i<7;i++)
{
*(p4[i]->number)=i+3+'0';
}
strcpy(p4[7]->number,"10");
*(p4[8]->number)='J';
*(p4[9]->number)='Q';
*(p4[10]->number)='K';
*(p4[11]->number)='A';
*(p4[12]->number)='2';
}
@end wintersweet.h文件:
#import <Foundation/Foundation.h>
@interface wintersweet : NSObject
{
@public char color[10];
int bigorsmall; char number[3];
}
-(void)assignmentthree;
@end
wintersweet * p3[13];
wintersweet.m文件:
#import "diamonds.h"
#import "string.h"
#import "stdio.h"
@implementation diamonds
-(void)assignmentfour;
{
int i=0;
for(;i<13;i++)
{
p4[i]=[diamonds alloc];
p4[i]->bigorsmall=i+1;
strcpy(p4[i]->color, "diamonds");
}
for(i=0;i<7;i++)
{
*(p4[i]->number)=i+3+'0';
}
strcpy(p4[7]->number,"10");
*(p4[8]->number)='J';
*(p4[9]->number)='Q';
*(p4[10]->number)='K';
*(p4[11]->number)='A';
*(p4[12]->number)='2';
}
@end
heart.h:
#import <Foundation/Foundation.h>
@interface hearts : NSObject
{
@public char color[10];
int bigorsmall;
char number[3];
}
-(void)assignmenttwo;
@end
hearts * p2[13];
heart.m:
#import "hearts.h"
#import "string.h"
#import "stdio.h"
@implementation hearts
-(void)assignmenttwo;
{
int i=0;
for(;i<13;i++)
{
p2[i]=[hearts alloc];
p2[i]->bigorsmall=i+1;
strcpy(p2[i]->color, "hearts");
}
for(i=0;i<7;i++)
{
*(p2[i]->number)=i+3+'0';
}
strcpy(p2[7]->number,"10");
*(p2[8]->number)='J';
*(p2[9]->number)='Q';
*(p2[10]->number)='K';
*(p2[11]->number)='A';
*(p2[12]->number)='2';
}
@end
spade.h:
#import <Foundation/Foundation.h>
@interface spade : NSObject
{
@public char color[10];
int bigorsmall;
char number[3];
}
-(void)assignmentone;
@end
spade * p1[13];
spade.m:
#import "spade.h"
#import "string.h"
#import "stdio.h"
@implementation spade
-(void)assignmentone;
{
int i=0;
for(;i<13;i++)
{
p1[i]=[spade alloc];
p1[i]->bigorsmall=i+1;
strcpy(p1[i]->color, "spade");
}
for(i=0;i<7;i++)
{
*(p1[i]->number)=i+3+'0';
}
strcpy(p1[7]->number,"10");
*(p1[8]->number)='J';
*(p1[9]->number)='Q';
*(p1[10]->number)='K';
*(p1[11]->number)='A';
*(p1[12]->number)='2';
}
@end