Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8064289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:19:34+00:00 2026-06-05T11:19:34+00:00

I just made an app that just prints something up in the command line

  • 0

I just made an “app” that just prints something up in the command line (outpot)
heres an example –

http://img254.imageshack.us/img254/2853/3cc0a810d7564e39b05bade.png

Code:

Card.h:

#import <Foundation/Foundation.h>
@interface Card : NSObject {
    int CardValue;
    int CardType;
}
@property int CardValue,CardType;
@end

Card.m:

#import <Foundation/Foundation.h>
@interface Card : NSObject {
    int CardValue;
    int CardType;
}
@property int CardValue,CardType;
@end

Deck.h:

#import <Foundation/Foundation.h>
#import "Card.h"
@interface Deck : NSObject {
    NSMutableArray *Deck1, *Deck2, *Deck3, *Deck4, *Deck5;
}
@property NSMutableArray *Deck1, *Deck2, *Deck3, *Deck4, *Deck5;
-(void)createDeck;
-(void)createFullDeck : (Deck *) TheDeck;
-(void)insertToDeck : (Card *) TheCard;
@end

Deck.m:

#import "Deck.h"
#include <stdlib.h> 
@implementation Deck
@synthesize Deck1, Deck2, Deck3, Deck4, Deck5;
-(void)createDeck{
Deck1 = [NSMutableArray arrayWithCapacity:13];
Deck2 = [NSMutableArray arrayWithCapacity:13];
Deck3 = [NSMutableArray arrayWithCapacity:13];
Deck4 = [NSMutableArray arrayWithCapacity:13];
Deck5 = [NSMutableArray arrayWithCapacity:13];
}
-(void)createFullDeck : (Deck *) TheDeck{
    Card *Card1 = [[Card alloc]init];
    [TheDeck createDeck];
    for (int i=1;i<=4;i++){
        for (int j=1;j<=13;j++){
            Card1.CardValue=j;
            Card1.CardType=i;
            [TheDeck insertToDeck:Card1];
        }
    }
}
-(void)insertToDeck : (Card *) TheCard{
if (TheCard.CardType==1)
    [Deck1 addObject:[NSNumber numberWithInteger:TheCard.CardValue]];
if (TheCard.CardType==2)
    [Deck2 addObject:[NSNumber numberWithInteger:TheCard.CardValue]];
if (TheCard.CardType==3)
    [Deck3 addObject:[NSNumber numberWithInteger:TheCard.CardValue]];
if (TheCard.CardType==4)
    [Deck4 addObject:[NSNumber numberWithInteger:TheCard.CardValue]];
}
-(id)DrawCard{
    Card *MethodCard = [[Card alloc]init];
    int randomType = arc4random() % 4;
    if (randomType==0){
        int DeckCount = [Deck1 count];
        int randomValue = arc4random() % DeckCount;
        MethodCard.CardValue = [[Deck1 objectAtIndex:randomValue]integerValue];
        [Deck1 removeObjectAtIndex:randomValue];
    }
    if (randomType==1){
        int DeckCount = [Deck2 count];
        int randomValue = arc4random() % DeckCount;
        MethodCard.CardValue =[[Deck2 objectAtIndex:randomValue]integerValue];
        [Deck2 removeObjectAtIndex:randomValue];
    }
    if (randomType==2){
        int DeckCount = [Deck3 count];
        int randomValue = arc4random() % DeckCount;
        MethodCard.CardValue =[[Deck3 objectAtIndex:randomValue]integerValue];
        [Deck3 removeObjectAtIndex:randomValue];
    }
    if (randomType==3){
        int DeckCount = [Deck4 count];
        int randomValue = arc4random() % DeckCount;
        MethodCard.CardValue =[[Deck4 objectAtIndex:randomValue]integerValue];
        [Deck4 removeObjectAtIndex:randomValue];
    }
    MethodCard.CardType = randomType+1;
    return MethodCard;
}
@end

Game.h:

#import <Foundation/Foundation.h>
#import "Deck.h"
@interface Game : NSObject

-(void)StartNewGame : (Deck *) TheDeck : (Game *) TheGame;
-(BOOL)GetDecision : (int) TheNumber;
-(void)CheckHiOrLo : (int) FirstNumber : (Deck *) TheDeck : (Game *) TheGame;
@end

Game.m:

#import "Game.h"
@implementation Game
-(void)StartNewGame : TheDeck : (Game *) TheGame{
    NSLog(@"Welcome to the game High-Low!");
    [TheDeck createDeck];
    [TheDeck createFullDeck:TheDeck];
    Card *TheCard = [[Card alloc]init];
    TheCard = [TheDeck DrawCard];
    [TheGame CheckHiOrLo: TheCard.CardValue : TheDeck : TheGame];
    }
-(BOOL)GetDecision : (int) TheNumber{
    int userNum=0;
    NSLog(@"The Card is %i\nif you think the next Card is going to be higher - type 1.\nif you think the next Card is going to be lower - type 0.", TheNumber);
    scanf("%i", &userNum);
    if(userNum==1)
        return YES;
    if(userNum==0)
        return NO;
    NSLog(@"error in GetDecision in Game.m");
    return NO;
}
-(void)CheckHiOrLo : (int) FirstNumber : (Deck *) TheDeck : (Game *) TheGame{
    Card *TheCard = [[Card alloc]init];
    TheCard = [TheDeck DrawCard];
    BOOL Decision = [TheGame GetDecision:FirstNumber];
    if(FirstNumber>TheCard.CardValue){
        if(Decision==YES){
            NSLog(@"%i", TheCard.CardValue);
            NSLog(@"GameOver");
        }
        if(Decision==NO){
            NSLog(@"%i \nCorrect, Next Card", TheCard.CardValue);
            [TheGame CheckHiOrLo: TheCard.CardValue : TheDeck : TheGame];
        }
    }
    if(FirstNumber<=TheCard.CardValue){
        if(Decision==YES){
            NSLog(@"%i \nCorrect, Next Card", TheCard.CardValue);
            [TheGame CheckHiOrLo: TheCard.CardValue : TheDeck : TheGame];
        }
        if(Decision==NO){
            NSLog(@"%i", TheCard.CardValue);
            NSLog(@"GameOver");
        }
    }
}
@end

So now i try to make a iPhone app for that, so i made a new iphone project, moved the Card,Deck and Game Classes to the iPhone project and made a High button, a Low button, and a start button to buid a new deck.

now how do i do that when i click the Start Button, it will trigger the method createDeck and CreateFullDeck that are in Deck Class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:19:35+00:00Added an answer on June 5, 2026 at 11:19 am

    First you would make Deck a declared object in your header file of, lets say your UIViewController, make sure you #import Deck.h.

    #import "Deck.h"
    
    @interface MainViewController: UIViewController
    
          Deck *deck;
    @end
    

    Now, you can initialize your deck in -viewDidLoad method of MainViewController

    -(void)viewDidLoad {
    
        [super viewDidLoad];
    
         deck = [[Deck alloc] init];
     }
    

    On your button action, you will create the full deck. Assuming this is an IBAction connected to a UIButton in Interface Builder;

     -(IBAction)onCreateClicked:(id)sender {
    
          [deck createDeck:deck];
          // You now created your deck of cards.
       }
    

    Hope this helps !

    EDIT: After investigating your code further, There are numerous things wrong with your code, but above example will do what you’re asking to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got something happening with a little app that I made that I don't
I made an app that is just a simple counter that will keep track
I've made a very simple app that just displays a Google map. However, it
I've just started learning Objective-C and made a little compass app that will display
well, I just made such a hello world non-Flex app in FlashDevelop and packaged
I need to launch an app I've made just after login, before anything else
I just made my first .net website. I'm trying to use the following line
I just made my first website , and I notice that the elements start
I was just made aware of a bug I introduced, the thing that surprised
I'm getting started with making few redirect with .htaccess but I just made something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.