Results 1 to 4 of 4
  1. #1
    hd300 is offline Member
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Default converting methods into pseudo codes

    Hi all, can you convert some java codes methods from the card class in solitaire game into the pseudo codes. thanks


    public class Card
    {
    public static boolean IsAceBiggest = true;

    private String rank;
    private String suit;
    public String Color

    public string NumberString
    {
    get
    {
    switch (rank)
    {
    case CardRank.Ace:
    return "A";
    case CardRank.Jack:
    return "J";
    case CardRank.Queen:
    return "Q";
    case CardRank.King:
    return "K";
    default:
    return Number.ToString();
    }
    }
    }

    private Deck deck;
    public Deck Deck
    {
    set
    {
    if (deck.Game != value.Game)
    throw new InvalidOperationException("The new deck must be in the same game like the old deck of the card.");

    if (deck != value)
    {
    deck.Cards.Remove(this);
    deck = value;
    deck.Cards.Add(this);

    if (DeckChanged != null)
    DeckChanged(this, null);
    }
    }
    }

    private boolean visible = true;
    public boolean Visible
    {
    get
    {
    return visible;
    }
    set
    {
    if (visible != value)
    {
    visible = value;

    if (VisibleChanged != null)
    VisibleChanged(this, null);
    }
    }
    }

    private boolean enabled = true;
    public boolean Enabled
    {
    get
    {
    return enabled;
    }
    set
    {
    enabled = value;
    }
    }

    private boolean isDragable = true;

    public boolean IsDragable
    {
    get { return isDragable; }
    set { isDragable = value; }
    }

    public Card(CardRank rank, CardSuit suit, Deck deck)
    {
    this.rank = rank;
    this.suit = suit;
    this.deck = deck;
    this.deck.Game.Cards.Add(this);
    }

    public Card(int number, CardSuit suit, Deck deck)
    {
    this.rank = (CardRank)number;
    this.suit = suit;
    this.deck = deck;
    this.deck.Game.Cards.Add(this);
    }

    public int CompareTo(Card other)
    {
    int value1 = this.Number;
    int value2 = other.Number;

    if(Card.IsAceBiggest)
    {
    if (value1 == 1)
    value1 = 14;

    if (value2 == 1)
    value2 = 14;
    }

    if (value1 > value2)
    return 1;
    else if (value1 < value2)
    return -1;
    else
    return 0;
    }

    public void MoveToFirst()
    {
    MoveToIndex(0);
    }

    public void MoveToLast()
    {
    MoveToIndex(Deck.Cards.Count);
    }

    public void Shuffle()
    {
    MoveToIndex(Deck.Game.random.Next(0, Deck.Cards.Count));
    }

    public void MoveToIndex(int index)
    {
    Deck.Cards.Remove(this);
    Deck.Cards.Insert(index, this);
    }


    public override string ToString()
    {
    return this.NumberString + " of " + this.Suit.ToString();
    }

    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: converting methods into pseudo codes

    Um...I'm sure many of us could, but it's unlikely we would.
    I mean, this smacks of being your homework to me.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default Re: converting methods into pseudo codes

    That code isn't Java, it's a feeble attempt at C#; better ask at a Microsoft site.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default Re: converting methods into pseudo codes

    Actual code to psuedo code is easy. This is definitely a no brainer and you're asking for us to complete something for you. Good luck buddy.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

Similar Threads

  1. Help me re-write pseudo code?
    By csisdifficult in forum New To Java
    Replies: 15
    Last Post: 04-21-2011, 06:30 AM
  2. Pseudo-priorityQueue datastructure
    By leeple in forum Advanced Java
    Replies: 2
    Last Post: 03-01-2011, 11:30 AM
  3. pseudo code
    By jamiem in forum New To Java
    Replies: 4
    Last Post: 12-20-2010, 05:25 PM
  4. Providing pseudo Webcam
    By H@CK3R in forum New To Java
    Replies: 21
    Last Post: 09-28-2010, 06:08 AM
  5. [SOLVED] [HELP] converting methods
    By Gods Army in forum New To Java
    Replies: 5
    Last Post: 03-06-2009, 11:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •