Matching Drawn Card To Its GIF In ArrayList?

May 4, 2015

I'm creating a card game and I'm having trouble getting a card gif to display. A card is drawn from an 52 card deck arraylist, and I then need to match that drawn card with the similarly named gif in an arraylist of card gifs, to display the gif on a card GUI. I have put my game, card, deck and graphical class below:

Card -
public class Card {
public String number;
public String suit;
public Card(String n, String s) {
number = n;
suit = s;

[Code] ....

The arrayList of card gifs (which contains all 52 gifs for the cards) is in the graphical class and my arrayList that contains the deck of cards in textual form (that I've imported from a textfile) is in deck. The names of the gifs in the gif arraylist are the same as the card names in my textual card arraylist (for example, 3h.gif is 3h in my card arraylist), so I believe I can use a .equals statement to match the card that has been drawn to the gif.

Here is what the gifs look like in their folder, which is an arraylist in my graphical class :

Here is what the drawn card looks like after the textual card arraylist has been shuffled:

The brown card in that image isn't the displayed card that has been drawn, it's just a graphical deck that I put in, I can't get the card that has been drawn on the GUI to display on the actual card frame, as you can see.

View Replies


ADVERTISEMENT

Trading Card Game - Each Card Can Be Moved Around Like Chess Pieces

May 10, 2014

So I'm making a trading card game and each card can be moved around like chess pieces. So far, I've made the cards simple rectangles and detect if clicks are made within that rectangle and then move them appropriately, but I'm not sure if that's the best solution.

View Replies View Related

Hiding User-drawn Graphics

Apr 15, 2014

I'm creating a game called Mouse Trap and I'm having an issue with a graphic drawn using AWT. Basically, when the mouse collides with the cheese, I want the cheese to disappear, or call (cheese[i].hide()). However, the cheese does not appear. hide() works for all other objects that inherit from PFigure, but the cheese will not. It's created a major issue in my game, and basically the only task left to accomplish.I believe my problem lies within Cheese.java, method draw(). For example, if I replace it with an example drawing, this problem goes away!:

public void draw() {
Graphics g = panel.getGraphics();
g.setColor(Color.blue);
g.drawOval(x + width / 4 , y + 1, width / 2, height / 2);

[Code] ....

I have three classes below that most likely involve the problem, feel free to ask if you need the others.PFigure.java (This class cannot be changed as a requirement to my project)

import java.awt.*;
 public abstract class PFigure implements Comparable {
protected int x, y; // Current position of the figure
protected int width, height; // Drawn (displayed) this size
protected int priority; // Can use to determine "winner"
protected Panel panel; // Panel the figure lives on

[code]....

View Replies View Related

Swing/AWT/SWT :: Deleting Shape Drawn On JPanel

Apr 7, 2015

I want to delete the shape i have drawn on the panel. Here is my code

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;

[Code] ....

Why it is not deleting my rectangle.

View Replies View Related

Java Tictactoe Game Images Won't Paint / Be Drawn

Jul 24, 2014

I'm following this tutorial![URL] I've copied over a lot of the code and also copied/pasted other parts! I understand how it works, but I can't figure out why the "X" or "O" won't paint onto the screen when the window is clicked on! Only a button is drawn when I click on the screen.

/*
package tictactoe;
import javax.swing.*;
import java.awt.Image;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.Toolkit;//look into this library

[code]....

View Replies View Related

Is It Possible To Scan Logical Gates From Hand-drawn Image

May 12, 2015

I am thinking of a project for my university the teachers liked it but I am not sure if its even possible.I am trying to make an andriod app. What I want to do is take a picture of a hand drawn logic circuit (having the AND, OR, NOT ... gates) recognize the gates, and make a circuit in the moblie and run it on all possible inputs.

For this I will have to make a simulator on mobile, that I dont think is the hard part. The problem is how could recognize the gates from a picture. Example of logical circuit is attached ( assume its hand drawn )..I found out that theres a edge detection plugin in java but still I dont think its enought to recognize the gates. Please share any algorithm or any technique or tools that I can use to make this thing.

View Replies View Related

Swing/AWT/SWT :: Keeping Track Of Strings Drawn On JPanel Using Paint

Nov 1, 2014

So, I have this simple program that paints a string on JPanel using g2.drawString("Hello world", 40, 120). Basically, I want to be able to keep track of many strings on the JPanel at once. I'm not sure how to do this. For example, I would want to have an ArrayList of objects that keep track of these strings.

I want to be able to click-and-drag these strings so I will need to know there locations, etc.

Right now, using g2.drawString, it only draws the string. I want something like gw.draw(myStringObject).

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JFrame;
import javax.swing.JPanel;

[Code] .....

View Replies View Related

Moving Drawn Shape Around By Dragging And Resizing - Functions Do Not Work

Oct 16, 2014

This class is part of a homework assignment and I have a problem:

package event;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import model.Model;
import shapes.Rectangle;
import shapes.Shape;
import shapes.Line;
public class ShapeMouseHandler extends MouseAdapter {
private Model model;

[Code] .....

I want to be able to move a drawn shape around by dragging and resizing a given shape (I can click that on a panel, the choosing-mechanism works)

I have tried for a week now to get the move-by-dragging and resizing to work, no success. What the code should look like?

View Replies View Related

Java 2D Drawing Application - Shape Should Be Drawn As Mouse Is Dragged

Nov 4, 2014

Java 2D Drawing Application. The application will contain the following elements:

a) an Undo button to undo the last shape drawn.

b) a Clear button to clear all shapes from the drawing.

c) a combo box for selecting the shape to draw, a line, oval, or rectangle.

d) a checkbox which specifies if the shape should be filled or unfilled.

e) a checkbox to specify whether to paint using a gradient.

f) two JButtons that each show a JColorChooser dialog to allow the user to choose the first and second color in the gradient.

g) a text field for entering the Stroke width.

h) a text field for entering the Stroke dash length.

I) a checkbox for specifying whether to draw a dashed or solid line.

j) a JPanel on which the shapes are drawn.

k) a status bar JLabel at the bottom of the frame that displays the current location of the mouse on the draw panel.

If the user selects to draw with a gradient, set the Paint on the shape to be a gradient of the two colors chosen by the user. If the user does not chosen to draw with a gradient, the Paint with a solid color of the 1st Color.

Note: When dragging the mouse to create a new shape, the shape should be drawn as the mouse is dragged.

Java Code:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;

[Code] ....

Missing things for the code check boxes for color gradients, line width and dashed.

View Replies View Related

Creating Menu Using Java - Animating Drawn Object On Button Click

Nov 7, 2014

i would like to create a menu like below where if i clicked on "DRAW", a frame to draw will appear and when i clicked on animate, I can animate an object drawn. I tried on using JButton, but I donno how to customize the design n so I would like to know is there other ways so tat my menu will appear as below?

View Replies View Related

Matching Grouping Symbols

Nov 27, 2014

I need to write a program that checks whether a Java source-code file has correct pairs of grouping symbols and the program must implement the Stack<E> class to solve this problem.

Here is the file:
[a({b,c}x{d,e})%x]
(1+(2-3)/4+[(a-({b+c}*5)/2)+e]
(a{b(c]}a)

I tried something like this, but I'm not exactly sure what I am doing wrong:

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Stack;
public class Driver {

[Code] .....

View Replies View Related

Java Matching Game

Apr 14, 2015

I'm working on a Java matching game and I'm having a hard time wrapping my mind around it. What I'm having trouble with is how exactly to create an array so that my squares have random values. Then how do I get it to reveal and compare those values by clicking on two of them? Here is what I have so far:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

[code]....

View Replies View Related

Random Card Generator

Mar 16, 2015

I've been trying to get a card generator working, but hells bells nothing is easy in java (unless you already the correct answer) trying to figure out the correct way to apply a method you don't understand is like being asked for the German word for banana in Spanish class.

import java.util.Random;
import java.util.Scanner;
class jacktest
{
public static void main ( String[] args ) {
Random r = new Random();

[code]....

my next step might be using object (hammer >=computer)=watch telly instead.

View Replies View Related

Name And Address Matching From Oracle Database

Apr 26, 2015

I need a java program for getting name and address matching from oracle database. I need get all the customer name and address belonging to same person even if there is slight name and address changes are there.

James Smith
123 Broadway Av
Brownville, ME 04415

James S
123 Brodway Avenue
Brownville Junction, ME 04451

I am unable to get a best code for this and trying since long time.

View Replies View Related

Exception In Matching Parentheses Using Stacks

May 11, 2014

I am trying to write a program that checks for parentheses matching using stacks.This is my ArrayStack class.

public class ArrayStack{
private final int DEFAULT_SIZE=10;
public int tos;
Object[] array;
public ArrayStack(){
array=new Object[DEFAULT_SIZE];

[Code] ....

But the problem is when I compile matching I get an error as unreported exception EmptyStackException.must be caught or declared to be thrown. I think the problem is with exceptions which I don't have a good knowledge of.

View Replies View Related

Java Matching Braces Program?

Apr 17, 2014

Here if we give input from a text file from a disk and (a[b+c{d}]-v) is true and{a-(b]} is false but i get some syntax errors ...

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Stack;
public class Syste {
private static String expr;

[code]....

View Replies View Related

GUI Memory Game - Matching Images

Jun 30, 2014

Making a memory game where you click a square it turns over an image and you match the two pretty simple. My issue is my images are not displaying and I am not sure why everything looks correct to me.

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.Random;
public class MemoryApp extends JFrame {
static String Pics[] = {"beaver.JPG", "dawgs.jfif",

[Code] ....

View Replies View Related

Copy Matching Numbers From Two Arrays Onto New One

Jun 4, 2014

I want my function to return an array, with the array holding just the values of data that appear in good.

This is what should be returned:

{3, 5, 3, 2, 3, 3}

What is currently being returned:

{0, 3, 5, 3}

I didn't want to miss any numbers, so I decided to iterate through j for the "good" array, and then just i for the one that I was looking for matching numbers. Perhaps part of the problem is that if the condition is met, it goes to the next iteration of the loop. I'm not sure.

public class Arrays2 {
public static void main(String args[]){
int [] data = {8, 3, 5, 3, 7, 2, 8, 3, 3 };
int [] good = {5, 2, 3, 2};
int [] result = f2(data, good);
for (int i = 0; i < result.length; i++){

[Code] ....

View Replies View Related

Java Memory Matching Game

Feb 13, 2015

"A common memory matching game played by young children is to start with a deck of cards that contain identical pairs. For example, given six cards in the deck, two might be labeled

1, two might be labeled
2 and two might be labeled
3. The cards are shuffled and placed face down on the table.

The player then selects two cards that are face down, turns them face up, and if they match they are left face up. If the two cards do not match they are returned to their original position face down. The game continues in this fashion until all cards are face up.Write a program that plays the memory matching game. Use sixteen cards that are laid out in a 4x4 square and are labeled with pairs of numbers from 1 to 8. Your program should allow the player to specify the cards that she would like to select through a coordinate system.For example in the following layout:

1 2 3 4
--------------------
1 | 8 * * *
2 | * * * *
3 | * 8 * *
4 | * * * *

All of the cards are face down except for the pair 8 which has been located at coordinates (1,1) and (2,3). To hide the cards that have been temporarily placed face up, output a large number of newlines to force the old board off the screen.Use 2D array for the arrangement of cards and another 2D array that indicates if a card is face up or face down.Or, a more elegant solution is to create a single 2D array where each element is an object that stores both the cards value and face.Write a function that shuffles the cards in the array by repeatedly selecting two cards at random and swapping them.

Note:To generate a random number x, where 0<= x <1, use x=Math.random();.For example, multiplying y six and converting to an integer results in an integer that is from 0 to 5."I have been thinking about the algorithm and design of the question for a few hours.

View Replies View Related

Card Game War Comparing Rank

Oct 30, 2014

I am making the card game War, I have gotten fairly far without a huge snag but I have been working on this. I need to compare 2 cards to find the larger of the 2. I have a function that will do that, but it is comparing the wrong numbers. The function is comparing their index values but I need it to compare the card value. The card value is found at rank(card).

import java.util.Random;
import java.util.List;
import java.util.ArrayList;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.LinkedList;
import java.util.Collections;
 
[Code] ....

View Replies View Related

Random Bingo Card Generator

May 26, 2014

I'm trying to create a program that will be able to generate random Bingo cards. This is what I have so far.

Java Code:

import java.util.Random;
public class BingoCard
{
private int[][] card;

public BingoCard(Random random)
{
card = new int[5][5];
for (int c = 0; c < 5; c++)

[code]...

The problem with this program is that even with the checkForDuplicateValues method, which checks for duplicate values of a column and replaces the values, it still prints out bingo cards with duplicate values!

View Replies View Related

Implementing A Card Game In JAVA

Apr 19, 2015

I am facing with a JAVA code needed for my assignment.We are implementing a Card Game.. There is a Card Class which i have not included in the code below .We have a Dec class that has various arrays..

privateCard[] masterPack >> Is a master Pack that is initialized once and has all the 52 cards.

private Card[] cards >> Is the array that has the card values from masterPack array.

My problem is :

After I called the Deck object D1, it goes to the Deck COnstrucutor OK.It then populates the values of masterPack as per the allowmasterPack method.Then it stores the values of masterPack into cards array in the init method..I get an exception when line below is executed..

cards[pack * 52 + k]= masterPack[k];

I get a java.lang.NullPointerException error..

public class debug
{
public static void main(String[] args)
{
int pack = 1;
Dec D1;
D1 = new Dec(pack);

[oode]...

View Replies View Related

Java Application - What Certain Card To Be Validated

Jun 19, 2014

I have situation where i have hard coded values

this is my use case

I have a table called card which got list of card ,now in my java application i got validation which what certain card to be validated e,g mastro, visa, amex etc now i have problem when i create new card its throwing error because the new card is not in the hard coded values, the new card is not affected by the validation. How to approch this ....

View Replies View Related

Web Services :: Matching Images Pattern Recognition

Nov 27, 2014

I want to know that is it possible to match images in java and used in web? how is it possible?

View Replies View Related

Lottery Game Matching Numbers Error

Dec 11, 2014

import java.util.Scanner;
import java.util.Arrays;
public class LotteryTester {
public static void main(String[] args) { 
LotteryApplication lottery = new LotteryApplication();
int lotteryNumbersCount = lottery.getLotteryNumbers().length;
 
 [Code] ....

Everything works fine but when I run it the matching numbers tends to be off. For example I will type Enter in 1,1,1,1,1 for my 5 numbers. The lottery numbers will be 5,3,4,5,8 and it will say 1 number matched.

View Replies View Related

Prepaid Card - How To Call A Constructor In Main

Jul 3, 2014

I am trying to call a constructor from PrepaidCard class in my main method, but I am not sure how to proceed.

As seen below, both the PrepaidCard constructor and the setCardID method have the ability to set the card ID.

Java Code:

public class PrepaidCard {
public PrepaidCard(String id, int token) {
cardID = id;
tokenBalance = token;
} public void setCardID(String id, int token) {
cardID = id;
tokenBalance = token;
}
} mh_sh_highlight_all('java');

Now in this block of code, I can successfully pass the id and token value by calling the setCardID method from the PrepaidCard class.

Now I would like to call the PrepaidCard constructor from the PrepaidCard class to pass the id and token value, instead of using the setCardID method.

Java Code:

public class PrepaidCardTest {
public static void main(String[] args) {
PrepaidCard card2 = new PrepaidCard(id, token);
System.out.print("Enter Card2 cardID: ");
id = input.nextLine();
card2.setCardID(id, token);
}
} mh_sh_highlight_all('java');

How to call the PrepaidCard constructor from the PrepaidCard class, to successfully pass the id and token value, in my main method?

Specifically how to modify or replace this line of code so that it can correctly call the PrepaidCard constructor?

Java Code: card2.setCardID(id, token); mh_sh_highlight_all('java');

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved