Developing UNO Game In Java?
May 11, 2014
i can develop basic java programs but am not really good at it.I have been given this assignment of developing UNO game in java and have been given 10 days. How should i pursue and how should i start.I know the game rules.Do i need to learn swings for the same?
View Replies
ADVERTISEMENT
May 11, 2014
I am new to java, i can develop basic java programs but am not really good at it. How should i pursue and how should i start. I know the game rules.Do i need to learn swings for the same?
View Replies
View Related
May 25, 2014
am trying to Develop a download manager that will improve the downloading process, by splitting big files into different parts, and download each part of the file parallel and then combine them properly Just like JDownloader not really too complex like it though but more like it especially the split download part of it. I was able to get a script from some eBook but that doesn't really solve my problem as it only downloads pause and resumes which is not really what am looking for.
View Replies
View Related
Jan 26, 2014
Develop an algorithm for a Java program that takes as input a single letter and displays the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way:
2 = ABC 3 = DEF 4 = GHI 5 = JK 6 = MNO 7 = PQRS 8 = TUV 9 = WXYZ
The screen dialog might look like this: Enter a single letter, and I will tell you what the corresponding digit is on the telephone. R The digit 7 corresponds to the letter R on the telephone.
The program should display a message indicating that there is no matching digit for any non-alphabetic character entered by the user. Also, the application should recognize only uppercase letters. If a user enters a lowercase letter, the program should display an error message. Prompt the user with an informative message for the input value as shown above.
The application should include the input letter as part of the output.
Write the algorithm to solve this problem including steps for prompting the user, getting input from the keyboard, and displaying the results.
Write the Java program that you designed, using your algorithm as a guide. Use your algorithm as comments in the body of the main method.
Use proper indentation, and meaningful identifiers throughout the code.
View Replies
View Related
Dec 18, 2014
I post the code I'm developing for a tetris-based characters. The problem I have is that I can't print the piece within the board. I haven't any error.
Class Piezas
Java Code:
public class Piezas {
public Piezas() {}
//atributos
private int i;
private int j;
private char m[][];
private int formaPieza;
[Code] ....
View Replies
View Related
Jan 26, 2015
I am creating a simple tiled minecraft like game in java, but i dont know how to make the game loop.Here is the source:
package net.pltformgame.main;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
public class main extends JFrame implements KeyListener {
[code]...
I really dont know how i make the jump or the game loop.
View Replies
View Related
Jan 20, 2015
I'm building this custom project in stages, and I'm having difficulty getting the health of the player and the enemy to change. Upon compiling, I'll select weapon 1, then choose action 1 (basic attack), and the health of both the player and the enemy will stay at 15 and 10.There are no errors when compiling.
import java.util.Scanner;
public class CustomProject
{
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
it hp = 0;
int potionsleft = 0;
int choice1 = 0;
int weapon = 0;
int enemy1hp = 10;
//int newenemy1hp = 0;
[code]....
View Replies
View Related
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
Apr 10, 2015
The game has two players: x and o. The players take alternate turns, with player x moving first at the beginning of each game.
Player x starts at position (1,1) while o starts at (8,8).
Each turn, a player can move like a queen in chess (in any of the eight directions) as long as her path does not cross a square already filled in or occupied. After moving, the space vacated by the player is designated as filled and cannot be moved to again. Notice that only the space that was occupied is filled, not the entire path.
The game ends when one player can no longer move, leaving the other player as the winner.
The coordinate (1 1) indicates the top left hand side of the board.
The board is specified as a list of rows. Each row is a list of entries:
- is an empty square * is a filled in square x is the current position of the x player o is the current position of the o player
The board will always be 8 by 8.
Your player function should take in the parameters as described above and return a move as a list in the format (row column) within 1 minute. If you cannot move, return (nil nil). The Tournament Referees will check for this. If you return an illegal move, the other player (and the Tournament Referees) will detect it and you will lose.
Additionally if your time expires you will lose.
View Replies
View Related
May 10, 2014
I'm trying to create a tile based map JPanel but all I get is a white screen. I'm fairly new to the Java Swing and AWT package so I've been watching tutorials on YouTube so learn as much as I can.
I've got three classes: Window.java which includes the Main method, Panel.java which is the JPanel and Tile.java to draw all the images into an array.
Window.java:
import javax.swing.JFrame;
public class Window extends JFrame {
public Window() {
setTitle("Project");
setSize(500, 400);
[Code] .....
I've checked through everything and still cannot find what I'm doing wrong. I did try different codes but I just got errors instead.
View Replies
View Related
Dec 3, 2014
I have an battleship program that I would like to improve in performance. I know that using certain algorithms it can be improve however I am beginner in Java. I would like any recommendations and or hint in how to improve this game. The are 5 ships per game and the computers plays 10000. I just want to sink all ships in as many shots as possible.
Main class
package solution;
import battleship.BattleShip;
import java.awt.Point;
import java.util.List;
[Code] .....
View Replies
View Related
Nov 17, 2014
I have to make the connect 4 game be connect 3. Ive edited a code but I the math is over my head. These loop methods check the ways someone can win.
for (int j=0;j<7;j+=2)//need to change
{
if ((f[i][j+1] != " ")
&& (f[i][j+3] != " ")
&& (f[i][j+5] != " ")
&& (f[i][j+7] != " ")
&& ((f[i][j+1] == f[i][j+3])
&& (f[i][j+3] == f[i][j+5])
&& (f[i][j+5] == f[i][j+7])))
//end of loop
[code]....
View Replies
View Related
May 8, 2014
So I am creating a game in Java, the game works fine when I run it in Eclipse but when I export it it does not draw anything on the screen.
I added a try and catch for nullpointerexceptions but the game does not throw any nullpointerexceptions.
What is the problem?
The game seems to be finding all the images & resources since it does not throw any NullPointerExceptions...
View Replies
View Related
Apr 10, 2014
Java Code:
public class Game extends Canvas implements Runnable, KeyListener {
private static final long serialVersionUID = 1L;
public Game() {
setMinimumSize(new Dimension(width, height));
setMaximumSize(new Dimension(width, height));
setPreferredSize(new Dimension(width, height));
}
[code]...
I want to remove the extends Canvas from the top line and when I use JFrame to add canvas, I don't do add.(this, but instead I do add a canvas variable I make. So instead of extending I want to make a variable. But then how would I do the start, stop and run?I want to use Graphics, Canvas (Not Jpanel because I want to use BufferedImage) & JFrame. I don't want to extend Canvas, how could I use Canvas identically to shown above but instead of extending using it as a variable? or, how could I do this?
View Replies
View Related
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
Mar 8, 2015
Anyway I am creating a game for my A2 coursework, most commonly known as Checkers. I have completed my code and everything works as I had planned except that the CheckerBoard itself as well as the checkerpieces do not appear to be showing.
The section of were my board should be present is just a black space. Although my board does not appear to be displaying, all of the actions I perform on it such as clicking certain section produces the planned response, and although I've checked through my code I cannot work out what I've done wrong.
CheckerBoard content = new CheckerBoard(); // Sets the CheckerBoard values into the content to be used in the next line
application.setContentPane(content); // Container holds the values together, Content pane of the CheckerBoard
application.pack(); // Use preferred size of content to set size of application.
Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
application.setLocation( (screensize.width - application.getWidth())/2,
(screensize.height - application.getHeight())/2 );
[Code] ....
I have noticed is that within the BoardComplete(), if you change the setBackground(Color.BLACK) to WHITE, it will change the colour of the section to white, but the checkboard is still unshown.
View Replies
View Related
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
Nov 30, 2014
I am creating a Guessing game program in java code. I am having an issue with the guess class and main/tester class running. The instructions for the game are The computer generates a random # and the user must guess that number in 7 or fewer guesses. If the guesses exceed 7, then the game is over and the user is asked if they want to 'play again?'These are things I need to incorporate into my code:
If Statement
A Loop of some kind
At least three imported methods
At least two methods you create
Obtains input from the user
At least two instance variables
At least two local variables
Some form of concatenation
At least two calculations
import java.util.Random;
public class Guess
{
int computersNumber; // A random number picked by the computer.
int usersGuess = 0; // A number entered by user as a guess.
int guessCount = 0; // Number of guesses the user has made.
[code]...
View Replies
View Related
Nov 16, 2014
Recursion in a MineSweeper game. So far, when a user clicks on a square and it has a bomb on it, I reveal the bomb to the user - see clicked(). I also have the ability to show the user if the squares surrounding them have any adjacent bombs - see countAdjacentSquares().
However, I am having trouble with my fillZeros() recursive method. When a user clicks on a square that has zero bombs in its surrounding squares, it not only reveals that square, but also any adjacent squares (horizontally, vertically or diagonally adjacent) that also have zero bombs in its surrounding squares.
I don't have any recursion, if I click on a square with no bombs all it does it set the square to 0, but doesn't continue to check for other empty squares.
Java Code:
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class Square extends GameSquare
{
private boolean revealed = false;
private boolean squareHasBomb = false;
public static final int MINE_PROBABILITY = 10;
public int mineCount = 0;
[Code] ....
View Replies
View Related
Mar 12, 2015
Opoly works this way: The board is a circular track of variable length (the user determines the length when the game app runs). There is only one player, who begins the game at position 0.
Thus, if the board length is 20, then the board locations start at position 0 and end at position 19. The player starts with a reward of 100, and the goal of the game is to reach or exceed reward value 1000. When this reward value is reached or exceeded, the game is over. When the game ends, your program should report the number of turns the player has taken, and the final reward amount attained.
In Opoly the game piece advances via a spinner - a device that takes on one of the values 1, 2, 3, 4, 5 at random, with each of the five spin values equally likely.
Although the board is circular, you should draw the state of the board as a single "line", using an 'o' to represent the current player position, and * represent all other positions. Thus if the board size is 10, then this board drawing:
**o******
means that the player is at location 2 on the board.
Here are the other Opoly game rules:
If your board piece lands on a board cell that is evenly divisible by 7, your reward doubles.
If you land on the final board cell, you must go back 3 spaces. Thus if the board size is 20, the last position is position 19, and if you land there, you should go back to position 16. (If the position of the last cell is evenly divisible by 7, no extra points are added, but if the new piece location, 3 places back, IS evenly divisible by 7, then extra points ARE added).
If you make it all the way around the board, you get 100 points. Note that if you land exactly on location 0, you first receive 100 extra points (for making it all the around), and then your score is doubled, since 0 is evenly divisible by 7,
Every tenth move (that is, every tenth spin of the spinner, move numbers 10,20,30,... etc.), reduces the reward by 50 points. This penalty is applied up front, as soon as the 10th or 20th or 30th move is made, even if other actions at that instant also apply. Notice that with this rule it's possible for the reward amount to become negative.
Here is the driver class for the game:
import java.util.*;
public class OpolyDriver{
public static void main(String[] args){
System.out.println("Enter an int > 3 - the size of the board");
Scanner s = new Scanner(System.in);
int boardSize = s.nextInt();
[Code] ....
heres the methods:
REQUIRED CODE STRUCTURE: Your Opoly class must include the following methods (in addition to the Opoly constructor) and must implement the method calls as specified:
playGame - The top-level method that controls the game. No return value, no parameters. Must call drawBoard, displayReport, spinAndMove, isGameOver.
spinAndMove - spins the spinner and then advances the piece according to the rules of the game. No return value, no parameters. Must call spin and move.
spin - generates an integer value from 1 to 5 at random- all equally likely. Returns an integer, no parameters.
move - advances the piece according to the rules of the game. No return value, takes an integer parameter that is a value from 1 to 5.
isGameOver - checks if game termination condition has been met. Returns true if game is over, false otherwise. No parameters.
drawBoard - draws the board using *'s and an o to mark the current board position. Following each board display you should also report the current reward. No return value, no parameters.
displayReport - reports the end of the game, and gives the number of rounds of play, and the final reward. No return value, no parameters.
View Replies
View Related
May 9, 2015
Im trying to make a tic tac toe game that you play against the computer using a random number generator and two dimensional arrays for the game board. Im not trying to make a GUI, the assignment is to have the board in the console, which I have done. I have run into a few problems with trying to get the computer player to correctly generate 2 integers and have those two integers be a place on the game board. Here is my code so far.
import java.util.Random;
import java.util.Scanner;
public class TicTacToe {
private static Scanner keyboard = new Scanner(System.in);
private static char[][] board = new char[3][3];
public static int row, col;
[Code] ....
View Replies
View Related
May 10, 2014
I'm trying to create a tile based map JPanel but all I get is a white screen. I'm fairly new to the Java Swing and AWT package so I've been watching tutorials on YouTube so learn as much as I can. I don't know where I'm going wrong.
I've got three classes: Window.java which includes the Main method, Panel.java which is the JPanel and Tile.java to draw all the images into an array.
Window.java:
import javax.swing.JFrame;
public class Window extends JFrame {
public Window() {
setTitle("Project");
setSize(500, 400);
setLocationRelativeTo(null);
[Code] ....
Panel.java:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;
public class Panel extends JPanel implements Runnable {
private Image dbImage;
[code]....
I've checked through everything and still cannot find what I'm doing wrong. I did try different codes but I just got errors instead.
View Replies
View Related
Sep 5, 2014
I had a game written in a 500x400 window using JFrame and a threaded JPanel. It used KeyListener to detect user input and worked just fine, problem was it was very click dependent and therefore I wanted to put it into fullscreen mode so I would no longer come across the problem of clicking outside the window and being taken out of the game. But when I ported the game to Full Screen Exclusive Mode the KeyListener no longer seems to be working and I have no clue why. I tried using KeyBindings as well, that code didn't work and is left commented out in the FSEM code.Here is my code for the windowed application:
import java.awt.Container;
import javax.swing.*;
public class Main extends JFrame{
private GamePanel panel;
public Main(){
panel = new GamePanel();
[code]....
View Replies
View Related
Nov 1, 2014
I want to design an open-answer quiz game using Java. Basically, the plan is to design a quiz where the name of a medicine is displayed as "the question" and the player will need to input the unique code (as "the answer") of the medicine in an open box (all the codes are two characters). The list has about 204 named medicine (with potentially more to be included at a later stage). The questions will not appear in the same order for each session restarted; they will appear randomly.
The player will have 60 seconds, and for each correct answer, will score 1 point and add 2 seconds to the timer. The player will also have 6 "lives", and for each incorrect answer, the player will lose a life, with no effect on the time.
The idea of the game is that the player memorise as many of these medicine codes as possible.
View Replies
View Related
Dec 6, 2014
I am trying to make a java Simon game but I cannot figure out how to make the GUI work. I have this so far, but now it just keeps saying I lose and it isn't functioning. It seems the only way I can make it work is having the action listeners in the do loop, but then once a button is clicked, the code errors out.
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
[code]....
View Replies
View Related
Apr 24, 2015
try to make a game in this code i am trying to make the basics i have made a mouse it should move the game code is
import java.applet.Applet;
import java.awt.*;
public class Game extends gameLoop {
public void init()
{
setSize( 854 , 480);
Thread th = new Thread (this);
[code]...
View Replies
View Related