stacks in java

stacks in java

i am doing a program that i have to finish it before monday so i only have tomorow to finish it. it about the stacks im designing the role of spider card game. i have to move more than one card together from one column to another i can move one card usinf pop and push method but if its more that one card togther for example if i want to move 6,5 and 4 to put it in another column in the top of 7. i dont know what to use to move them together. this is the method that im having the problem with currently it moves one card to another columna and only if its in the right order and then if the column is empty then it has to add only jack or bigger card. then the part where im have problem with which to move a list of cards together. please i need help urgently..... thank you


* @pre 0<=c<7 (i.e. the index of the source column is within range)
* && 0<=d<7 (i.e. the index of the target column is within range)
* && 0<=i<columns[c].size() (i.e. the index i is within range)
* && the i-th card in the c-th column is face up
*
* @post If the rules permit, the i-th card of the c-th column has
* been moved onto the bottom of the d-th column, (along with any
* cards displayed below it), leaving all other cards where they were.
* If the rules do not permit this move, all cards are left
* where they were before.
*

public void moveCardBetweenColumnsIfPossible(int c, int i, int d){

CardStack stack = new CardStack();

if (columns[d].isEmpty()&& columns[c].peek().getRank()>=Card.JACK){
Card move=columns[c].pop();
columns[d].push(move);
}

if (((!columns[d].isEmpty()&& columns[c].peek().getRank()==columns[d].peek().getRank()-1))&& (!columns[c].peek().getColour().equals(columns[d].peek().getColour())))
{
Card value=columns[c].pop();
columns[d].push(value);


// to move a list of cards together i is the selected card and d is the destination where you want to move the card to and c is the coloumn

for( int I = columns[c].size() - 1 ; I >= i ; I--)
{


Card card = columns[c].peek();
columns[c].pop();

stack.push(card);


while(!stack.isEmpty())


columns[d].push(columns[c].peek());


}
}

}
View Answers









Related Tutorials/Questions & Answers:
stacks in java - Java Beginners
stacks in java  i am doing a program that i have to finish it before monday so i only have tomorow to finish it. it about the stacks im designing the role of spider card game. i have to move more than one card together from one
Java Stacks - Java Beginners
Java Stacks  Hello..Help me with this assignment plzz. Programming Assignment: A) Consider the outpatient pharamacy at University Hospital. At the entrance of the pharmacy, the patient gives his prescriptions
Advertisements
Java Convert decimal to binary using Stacks
Java Convert decimal to binary using Stacks In this section, you will learn how to convert decimal into binary using stacks. You all are aware of Stacks. It performs two basic operations push and pop. The push operation adds an element
ModuleNotFoundError: No module named 'stacks'
ModuleNotFoundError: No module named 'stacks'  Hi, My Python... 'stacks' How to remove the ModuleNotFoundError: No module named 'stacks'... to install padas library. You can install stacks python with following command
ModuleNotFoundError: No module named 'python-stacks'
ModuleNotFoundError: No module named 'python-stacks'  Hi, My... 'python-stacks' How to remove the ModuleNotFoundError: No module named 'python-stacks' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks-image'
ModuleNotFoundError: No module named 'stacks-image'  Hi, My Python... 'stacks-image' How to remove the ModuleNotFoundError: No module named 'stacks-image' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks-snippet'
ModuleNotFoundError: No module named 'stacks-snippet'  Hi, My... named 'stacks-snippet' How to remove the ModuleNotFoundError: No module named 'stacks-snippet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks_summary'
ModuleNotFoundError: No module named 'stacks_summary'  Hi, My... named 'stacks_summary' How to remove the ModuleNotFoundError: No module named 'stacks_summary' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks-twitter'
ModuleNotFoundError: No module named 'stacks-twitter'  Hi, My... named 'stacks-twitter' How to remove the ModuleNotFoundError: No module named 'stacks-twitter' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks-embed'
ModuleNotFoundError: No module named 'stacks-embed'  Hi, My Python... 'stacks-embed' How to remove the ModuleNotFoundError: No module named 'stacks-embed' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks-featuredlink'
ModuleNotFoundError: No module named 'stacks-featuredlink'  Hi, My... named 'stacks-featuredlink' How to remove the ModuleNotFoundError: No module named 'stacks-featuredlink' error? Thanks   Hi
ModuleNotFoundError: No module named 'stacks-page'
ModuleNotFoundError: No module named 'stacks-page'  Hi, My Python... 'stacks-page' How to remove the ModuleNotFoundError: No module named 'stacks-page' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'stacks-snippet'
ModuleNotFoundError: No module named 'stacks-snippet'  Hi, My... named 'stacks-snippet' How to remove the ModuleNotFoundError: No module named 'stacks-snippet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks-textblock'
ModuleNotFoundError: No module named 'stacks-textblock'  Hi, My... named 'stacks-textblock' How to remove the ModuleNotFoundError: No module named 'stacks-textblock' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'stacks-twitter'
ModuleNotFoundError: No module named 'stacks-twitter'  Hi, My... named 'stacks-twitter' How to remove the ModuleNotFoundError: No module named 'stacks-twitter' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangocms-stacks'
ModuleNotFoundError: No module named 'djangocms-stacks'  Hi, My... named 'djangocms-stacks' How to remove the ModuleNotFoundError: No module named 'djangocms-stacks' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'stacks-page'
ModuleNotFoundError: No module named 'stacks-page'  Hi, My Python... 'stacks-page' How to remove the ModuleNotFoundError: No module named 'stacks-page' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'stacks-textblock'
ModuleNotFoundError: No module named 'stacks-textblock'  Hi, My... named 'stacks-textblock' How to remove the ModuleNotFoundError: No module named 'stacks-textblock' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'stacks-contentgroup'
ModuleNotFoundError: No module named 'stacks-contentgroup'  Hi, My... named 'stacks-contentgroup' How to remove the ModuleNotFoundError: No module named 'stacks-contentgroup' error? Thanks   Hi
ModuleNotFoundError: No module named 'stacks-image'
ModuleNotFoundError: No module named 'stacks-image'  Hi, My Python... 'stacks-image' How to remove the ModuleNotFoundError: No module named 'stacks-image' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'stacks_summary'
ModuleNotFoundError: No module named 'stacks_summary'  Hi, My... named 'stacks_summary' How to remove the ModuleNotFoundError: No module named 'stacks_summary' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'wagtail-stacks'
ModuleNotFoundError: No module named 'wagtail-stacks'  Hi, My... named 'wagtail-stacks' How to remove the ModuleNotFoundError: No module named 'wagtail-stacks' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'wagtail-stacks-embed'
ModuleNotFoundError: No module named 'wagtail-stacks-embed'  Hi...: No module named 'wagtail-stacks-embed' How to remove the ModuleNotFoundError: No module named 'wagtail-stacks-embed' error? Thanks   Hi
ModuleNotFoundError: No module named 'wagtail-stacks-featuredlink'
ModuleNotFoundError: No module named 'wagtail-stacks-featuredlink'  ...: No module named 'wagtail-stacks-featuredlink' How to remove the ModuleNotFoundError: No module named 'wagtail-stacks-featuredlink' error? Thanks
ModuleNotFoundError: No module named 'wagtail-stacks-image'
ModuleNotFoundError: No module named 'wagtail-stacks-image'  Hi...: No module named 'wagtail-stacks-image' How to remove the ModuleNotFoundError: No module named 'wagtail-stacks-image' error? Thanks   Hi
implementation of stacks using linked lists in c++
implementation of stacks using linked lists in c++  how to implementation of stacks using linked lists in c++   #include<stdio.h> #include<stdlib.h> #include<conio.h> struct node{ int data
Java stack help
Java stack help  How would I use stacks in java to do a calculation like: 4*((3+3)/(5-3
making trees - Java Beginners
making trees   pls i do't know what this yerms mean in terms of java trees and stacks? Inorder traverse Switch statement Doing something to the stack thanks in advance
java programming - Java Beginners
java programming  how can i program the queue and the stacks.   Refer Complete Reference  Hi friend, import java.util....) ; } } ----------------------------------------- Read for more information. http://www.roseinida.net/java/ Thanks
hashtable - Java Beginners
hashtable  pls what is a hashtable in java and how can we use it to compine queue and stacks. thnks in advance.  Hi , A hash-table...://www.roseindia.net/java/ Thanks. Amardeep
Use a tree stack to sort number in java?
Use a tree stack to sort number in java?  The Question is : Three stacks can be used to sort a list of numbers. Assuming stack in holds the input list of numbers, stack out is to hold the output list after sorting the numbers
Use a tree stack to sort number in java?
Use a tree stack to sort number in java?  The Question is : Three stacks can be used to sort a list of numbers. Assuming stack in holds the input list of numbers, stack out is to hold the output list after sorting the numbers
Use a tree stack to sort number in java?
Use a tree stack to sort number in java?  The Question is : Three stacks can be used to sort a list of numbers. Assuming stack in holds the input list of numbers, stack out is to hold the output list after sorting the numbers
Use a tree stack to sort number in java?
Use a tree stack to sort number in java?  The Question is : Three stacks can be used to sort a list of numbers. Assuming stack in holds the input list of numbers, stack out is to hold the output list after sorting the numbers
Use a tree stack to sort number in java?
Use a tree stack to sort number in java?  The Question is : Three stacks can be used to sort a list of numbers. Assuming stack in holds the input list of numbers, stack out is to hold the output list after sorting the numbers
Use a tree stack to sort number in java?
Use a tree stack to sort number in java?  The Question is : Three stacks can be used to sort a list of numbers. Assuming stack in holds the input list of numbers, stack out is to hold the output list after sorting the numbers
Core Java Interview Question, Interview Question
Core Java Interview Question Page 2   ... the main difference between a Vector and an ArrayList Answer: Java Vector class... the difference between a queue and a stack? Answer: Stacks works by last-in-first-out
Infix to Prefix - Java Beginners
Infix to Prefix  Hello, I needed help on converting from an infix expression to a prefix expression using stacks.  Hi Friend, Try the following code: import java.io.*; import java.util.*; public class
Core Java Interview Question, Interview Question
Core Java Interview Question Page 24  ...(String args[]) method in Java Answer: We need ADS_TO_REPLACE_1 public... serialization Answer: Serialization means storing a state of a java object
Java Convert Infix to Postfix
Java Convert Infix to Postfix In this tutorial, you will learn how to convert expression from infix to postfix. The given code accepts the expression from the user and display its postfix expression by using Stacks. Example
Java Args example
Java programs? I've tried many times, but I am successful only in loading... of concept for the Java Debugger API. The Java Debugger API allows us to actually... and stacks. However, these commands are really beyond the scope of a jdb intro. One
Prefix / Postfix to Infix
from India and thus, I don't know how to make the program using stacks, pop etc (the teacher required that we do this). We are using Java / Eclipse. Any code
java
java  diff bt core java and java
java
java  what is java
DOJO Tutorial
, queues and stacks. Dojo applications are used where the JavaScript and browsers
DOJO Tutorial
, queues and stacks. Dojo applications are used where the JavaScript and browsers
JAVA
JAVA  how the name came for java language as "JAVA
java
java   why iterator in java if we for loop
java
java  explain technologies are used in java now days and structure java
java
java  different between java & core java

Ads