FC Barcelona Database - Updating Number Of Games Played By The Player
May 25, 2014
So I am working on a database pertaining FCBarcelona. I have three classes FCBarcelona.java Player.java and Roster.java
I am working on a method that updates the number of games played by the player ... Its not working it gives a runtime error ...
Roster.java
public Player changeNumGamesPlayed(Player nPlayer)
{
int index = play.indexOf(nPlayer);
if(index == -1)
return null;
[Code] .....
View Replies
ADVERTISEMENT
Apr 2, 2014
Its a basic program that is played by 2 people. Player one is suppose to type a number and the second player is suppose to guess the number. However after I test it out, and if I guess too low or too high I get stuck in "Your guess is too low, try again." infinite loop, what is wrong.
import java.io.*;
class GuessingGame
{
public static void main (String[] args) throws IOException
{
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
String firstPlayer, secondPlayer;
int firstInput, secondInput;
int guessCount = 0;
[Code] .....
View Replies
View Related
Aug 22, 2014
/*
/ GuessGame.java
*/
import java.util.Scanner;
import java.util.Random;
public class GuessGame {
public static void main(String[] args) {
[code]....
tracking the number of games played, and also when running the code, I have to press "1" twice for it to actually load up the game again.
View Replies
View Related
Feb 21, 2014
I am trying to use a prepareStatement to update the database but I am getting an error on setInt - cannot find symbol and on the executeUpdate() I get error no suitable methods for executeUpdate (no arguments)
public Products UpdateProductsDB() {
pool = ConnectionPool.getInstance();
connection = pool.getConnection();
try {
stmt = connection.prepareStatement("UPDATE products SET qtyonhand=?, qtysold=? WHERE id=?");
} catch (SQLException ex) {
[Code] ....
I used similar code for an insert statement and I don't have these problems
View Replies
View Related
Feb 10, 2015
I'm doing an application which needs a JTable with data from an existing database. I need the table to periodically (I plan to use a Timer) reflect the changes made to the DB (inserting new rows, deleting or updating existing rows) without making the dirty approach of clearing the whole JTable and refilling it again, which is not nice. I need to just add/modify/delete the needed rows, not the whole table.
View Replies
View Related
Nov 13, 2014
I have a question about Frames per second in games. In a simple game i should be able to pull off 60(exactly), right? So if i have this code for a game loop:
while(shouldRun){
Thread.sleep(1000/60);
//loop code here
}
will that run at 60 fps?
The loop code takes a tiny bit of time, then it waits for (a second/60), so overall the code will be running overall since the code takes some time?
Is this the case , and if so is there a solution?
View Replies
View Related
Nov 23, 2014
building a game. the game is all about the multiple times table with levels. easy medium and difficulty. I dont even know where to begin and what is the codes to use or even the platform. what websites can be access etc and what is the big deal with code tags.
View Replies
View Related
Jul 24, 2014
I am having a problem with my java program. My goal is to request the user to enter how many times they want to roll a pair of dices. Each dice have numbers 1-6. When rolling the dices, I randomly pick a number from each dice and total the number. My goal is to calculate the number of times snake-eyes was rolled which is a total of 2 and total number of times a total of 7 was rolled. Here is my code. I am calling the rollDice method to perform the random pick and calculations. The error I am getting is at the bottom of the code.
package dice;
import java.util.Scanner;
import java.util.Random;
public class Dice
{
public static void main(String[] args)
{
int numRolls; // number of rolls
[code]...
How many times would you like to roll the two dice? 1000 Exception in thread "main" java.lang.NullPointerException at dice.Dice.main(Dice.java:40)
Java Result: 1 BUILD SUCCESSFUL (total time: 4 seconds)
View Replies
View Related
Jun 6, 2013
I am unable to open Pogo Poker with out receiving an error message saying "Oops, Java is not detected on your computer" (or something similar). I have reinstalled it several times and get the same results.
View Replies
View Related
Feb 14, 2013
Recently we updated out database and we changed our tables' and columns' names, I'm developing an adf application with EJB3.0 the question is that the new column names start with a number (eg. 001U_ID), its a kind of encoding the names of the tables so no one can modify the values.
When I create a query on the table it is throwing an exception:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'U_ID'.
I think the problem is that the EJB3.0 doesn't recognize column names starting with a number!!! What can I do to solve this issue?
View Replies
View Related
Jul 14, 2014
HTML Code:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
import javax.imageio.ImageIO;
public class Main extends JApplet implements Runnable, ActionListener {
[Code] .....
I am making a game and there are two problems that I have and can't seem to solve. I never made on applet before, and I'm not good with the swing components, but I am decent programming in Java.
Problem #1: the start button is in the JPanel, I don't want that, I want it to be above the JPanel.
Problem #2: I want to put images in to a JTable for organization and character selection purposes, but I keep on getting a string. Do I have to use an ImageIcon to get it to work, or does it matter?
In case you were wonder what kind of game I'm making, I'm making one of those jump games where you jump on platforms and try to go as high as you can without missing a platform. There is going to be character selection for the jumper, and the jumpers are going to be food, like a potato, a banana, a strawberry, etc.
View Replies
View Related
Feb 24, 2014
I am using the Netbeans IDE for Java creations. What are the steps of creating a media player using Java thru Netbeans as i don't understand most of the jargon and the forms,classes,etc.I don't want to use JavaFx but plain Java Application.I am coming from a Delphi pascal background.
View Replies
View Related
Jul 6, 2014
I am trying to create an MP3 player with a totally customized look and feel to it. I know how to do this with .net, but I must be missing something in Java.
I want to be able to NOT have to present the user with the default mediaPlayer.getControlPanelComponent() in order to control the media player. I want to be able to code it to when the user clicks on my "Play" button, I can tell the player to play the song, and so on.
so far I get this far:
try {
player = Manager.createPlayer(playit.toURI().toURL());
player.start();
//Component c = player.getControlPanelComponent();
} catch (IOException | NoPlayerException ex) {
Logger.getLogger(TagTester.class.getName()).log(Level.SEVERE, null, ex);
}
...but cannot seem to find out where to go from there.
If familiar with AxWindowMediaPlayer in .NET, I am looking for something similar to:
AxWindowMediaPlayer.Ctlcontrols.play()
when my "Play" button is clicked.
View Replies
View Related
Nov 25, 2014
So I have a player an enemy and enemy bounds the enemy can go. I need to have the enemy track my position and when I go into the position (I am using a collision method for this) the enemy comes over at a speed of 1. My problem is the enemy jumps to me and then follows at speed of 2 (2 is the player speed). The code is wrong this is why it is jumping and I have my other problems. so my question is what is a good solution for this? I am trying to make a method to track playerposition() so what I am thinking I could do is find x, y of player then store those into an array and return the array to Enemy so he tracks.
player.java
public class Player{
int x = 100; // Location of player
int y = 200; // location of player
int xa = 0; // Representation of where the player goes
int ya = 0; // Representation of where the player goes
private int speed = 2;
[Code] .....
Please note this is not the entire code I have cut some things out that did not need to be there. Also, the code is just to get an idea of what I was thinking of doing. The ideas that are came up with are not meant to be a reflection of what I already have but, what I could add or replace.
View Replies
View Related
Dec 5, 2014
I am currently building a java music player and need getting the volume control to work. I want to be able to set the computers volume directly using an integer. I've created a slider and put the value into an integer. The part that I am having trouble with is getting the volume to work.
View Replies
View Related
Mar 19, 2014
I wrote a single player blackjack code and i want to play this game with multiplayers, which steps should i take to do this
package blackjack;
import java.util.Random;
import java.util.Scanner;
public class Blackjack {
public static void main(String[] args) {
Random kagit=new Random ();
[Code] .....
View Replies
View Related
Feb 24, 2014
i want to design a media player but my program can't play any song it is showing me error "Uncompilable source code - cannot find symbol
symbol: class MediaPanel
location: class media.Media
at media.Media.main(Media.java:28)"
This is my code.
package media;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JFileChooser;
[Code] .....
I got the code from [URL] .....
View Replies
View Related
May 19, 2014
I have already tried every possible way for removing this bug but all failed. The problem is that sometimes my player passes through the map tiles, i mean, the algorithm is like -- if not colliding, move in required direction; else if colliding, move in opposite direction. But sometimes the second condition fails i dont understand why.
private void movement(){
left=bindObject.getLeft();
right=bindObject.getRight();
up=bindObject.getUp();
down=bindObject.getDown();
bindObject.setColliding(colliding);
[Code] .....
Where bindObject is a class which contains key bindings of following keys:-
left arrow key (when pressed) , left arrow key (when released),
right arrow key (when pressed), right arrow key (when released),
up arrow key (when pressed), up arrow key (when released),
down arrow key (when pressed), down arrow key (when released)
View Replies
View Related
May 27, 2014
I am creating a hangman code. So the game i am creating is 2 player, first player enters the word and second player guesses. i made the code but i don't know how to restrict the first player from adding random characters into the secret word because for my project the word can only contain letters. so i need making the code so the player 1 can only enter letters.
My code is below:
/**
* Auto Generated Java Class.
*/
import java.util.Scanner;
public class Hangman {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
String player1,player2;
int wrongguessamount = 0; //keeps the count of the amount of wrong guesses
int correctguessamount = 0; //keeps count of the amount of correct guesses
int maxincorrect=6;//makes sure the user cant guess more than 6 times
[Code] .....
View Replies
View Related
Jan 14, 2014
I am making a game with java in a program called greenfoot.My problem is that a sound won't play when the player dies and a Game Over screen pops up..
- I have saved the audio file in my sound map of the scenario
- Applied the good name of the file
- tested the sound effect and it's working
this is my code:
public GameOver()
{
setImage(new GreenfootImage("GAME OVER", 100, Color.BLACK, null));
Greenfoot.playSound("fail-trombone-03.wav");
Greenfoot.stop();
}
View Replies
View Related
Sep 16, 2014
So I am trying to create a Multi-Player game in java, and I have a Game server and a Client. They normally connect with either but I would like to add a login server so that there can be an option to go to a different world then just the main one. It will have the same map and data but will be separate from the Players that are on world one per say. Now if you are on world two I would like it to have the option for you to be able to Private message players that are on World one. That is where the login server comes in to play.
I am still new at Java and would like to be able to understand Packets and how to handle them more clearly. So far I have gotten the basis of the login server connected to the server and the client connects to the server via the login server. But I am getting a bunch of "unhandled packets" and I would like to know how to handle them. Here are some bits of the code.
package com.ls.net;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
[Code] ....
So when I run my client this pops up in the console:
[Tue Sep 16 16:50:56 EDT 2014][LoginServer]: Finished initializing login server.
[Tue Sep 16 16:50:56 EDT 2014][SignalMultiplexer]: Unhandled packet: 15
[Tue Sep 16 16:50:56 EDT 2014][SignalMultiplexer]: Unhandled packet: 41
[Tue Sep 16 16:50:56 EDT 2014][SignalMultiplexer]: Unhandled packet: 74
[Code] ....
And here are the class's for Accounts:
package com.ls.net.codec.decoder.packets;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.ChannelHandlerContext;
import com.ls.bufutils.BufferUtils;
import com.ls.net.codec.decoder.PacketDecoder;
import com.ls.net.codec.decoder.handlers.AccountHandler;
[Code] ....
View Replies
View Related
May 15, 2014
Alright, so I'm having problems with lines 11 - 55. I'm trying to calculate the possible tiles the clicked unit can be moved on and display it to the player.
The field is a 9 (columns) by 5 (rows) grid. A unit with can move tiles horizontally or vertically based on its movement.
Example: (unit = o; possible tiles = x) (assuming movement of 2).
[ ][ ][ ][ ][x][ ][ ][ ][ ]
[ ][ ][ ][x][x][x][ ][ ][ ]
[ ][ ][x][x][o][x][x][ ][ ]
[ ][ ][ ][x][x][x][][ ][ ]
[ ][ ][ ][ ][x][ ][ ][ ][ ]
I tried to calculate movement by finding out what column the unit is in, subtracting the column it wants to go to, multiplying the difference by *-1 if the difference is less than 0. Then, doing the same with rows and adding the difference of columns to the difference of rows and comparing it to the unit's movement. Unfortunately, with my code, it seems to move in any directions.
@Override
public void mouseClicked(MouseEvent e) {
if (Main.cards.size() > 0) {
mainloop: for (int i = 0; i < Main.cards.size(); i++) {
Card c = (Card) Main.cards.get(i);
int startingColumn = 0;
[Code] ......
View Replies
View Related
Jun 28, 2014
I am trying to design a monopoly board game with a class and a main program. I can not make the method to keep track of the player's position after every roll. After every roll it prints "Previous position: 0".The player should also not go over 14th spot because the board is just 15 including 0. That is what I have (just the particular method and the part from the main program which call it).
public int getpospl1()
{
System.out.println( getplayer1name() + " Rolls "
+ "Dice 1: " + getrolld1() + "" + "Dice 2: " + getrolld2() + "" );
int spot1 = 14; //The end spot
int start = 0;
int previousPosition = start;
[Code] .....
View Replies
View Related
Apr 19, 2015
How to start and structure my program because i am fairly new to the program but want to try to make a game. My idea of the game is it generates random numbers between 1-100 for two people and the program compares the two random numbers and declares the player with the higher value the winner like the card game war. Then it would give you an option to try again.
View Replies
View Related
May 27, 2014
I have been working on this function and i can't get it to work. It's a little bit complicated so let me first explain what this is about:
1. As a little exam in my studies i have to program a halma console game with KI an stuff.
2. Everything is finished and works except for the Move-Calculation.
3. A Move is a Move from Field a to Field b which a player can perform in one round based on the game rules (Careful: We are not using the standard halma rules, we use different ones).
4. Class Move consists of the Starting Cell where the Figure before the Move stands and a target Cell where the figure will stay on at the Move end. It may include an Array of serveral Cells, the stop cells which the figure passes from start -> target since several jumps can be performed in one Move.
Valid Examples for Moves:
a -> b (From Field a to Field b)
d -> f through g,h,i (From Field d to Field f through the Field g,h,i
My Move Calculation where all possible Moves are calculated for a given figure consists of 2 parts. An expand() function which will generate all possible moves (works perfectly) and a jumpFix() function which isn't working properly.
Example:
After expand() I'm getting something like that:
a -> b
b -> c
c -> d
s -> t
This is however not finished, because the first 3 Moves are actually 1 Move. Because the player can Move from a -> d in one turn because those 3 are consecutive Move. The fixed Move would look like that:
a -> d through b,c
jumpFix() is also perfectly working for that situation, however there is one specific situation when it doesn't work. Let's say we have this situation.
a -> b
b -> c
c -> d
b -> e
e -> f
f -> g
s -> t
Then the only valid jumpFix() output would be:
a -> d through b,c
a -> g through b,e,f
s -> t
However i can not get it to work yet. Note: It definitely needs to be iterative, not rekursive else i would get an StackoverflowError.
This is my current Code of jumpFix():
Java Code:
/**
* Takes a look into all calculated moves and finds those which should be seen as one move, but are still considered to be more than one move (several jumps in one move)
*/
public static List<Move> jumpFix(List<Move> moves) {
Set<Move> result = new HashSet<Move>();
Set<Move> remove = new HashSet<Move>();
int lastSize = -1;
// repeat action until no moves could be merged
while (lastSize != remove.size()) {
[Code] ....
How to implement the special case where a Move splits into 2 or more branches and jumpFix() able to handle this case.
View Replies
View Related
Apr 29, 2014
I am using JSF2 with Primefaces. Here is my business requirement-Hidden field on JSF page should take the value from the session object that is set in managed bean. Session object is updated every time when the user submits the page. I am able to update the session object in the managed bean and able to get the value in the hidden field first time and after that i see the same value in the hidden field even though session object has different value. Here is the hidden field: <h:inputHidden id="xyz" value="xyz"/> i tried using sessionScope but still didn't work.
View Replies
View Related