Designing A Game That Simulates Roomba Robot Vacuum

Feb 14, 2014

I am designing a game that simulates a roomba robot vacuum and have most of the framework done. So I have random floating circles and the Roomba bot in the center. The boot is suppose to move with the arrow keys. However when i run the program and select the keys nothing happens. Here's my code.

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Ellipse2D;
import java.awt.Graphics;
import javax.swing.*;
public class Roomba extends JFrame implements ActionListener, KeyListener{
 
[Code] .....

View Replies


ADVERTISEMENT

Write A Static Method That Simulates Flip Of Weighted Coin

Apr 22, 2015

I am supposed to write a static method that simulates a flip of a weighted coin by returning either heads or tails each time it is called. The coin is twice as likely to turn up heads as tails. My idea was to of course use a random class

Random flip = new random

and somehow initialize it so 3 numbers are called and create if statements so that when 0 and 1 are called heads returns and when 3 is called tails is.How do I put all this together?

View Replies View Related

Designing Address Book In Java

Jan 12, 2014

I am designing an address book. I have come up with the following design:

Address Book:
Attributes : Entry
Methods: add(), delete(), search()

Entry:
Attributes : Name, Address, Phone Number
Methods: addName(),editName(),deleteName(),addPhone(),editPhone(),deletePhone(),addAddress(),editAddress(),deleteAddress()

Name:
Attributes: firstName, lastName

PhoneNumber:
Attributes:areaCode, phoneNumber

Address:
Attributes:streetNumber,streetName,city,zip.

View Replies View Related

How To Make Robot Print Out Colons

May 1, 2014

I've tried making my robot print out colons but I just can't seem to. I tried doing

Java Code:
robot.keyPress(KeyEvent.VK_COLON); mh_sh_highlight_all('java');

and

ava Code:
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_SEMICOLON); mh_sh_highlight_all('java');

And neither seem to work, in fact I can't seem to get any symbols typed out (I don't want to copy to clipboard and paste out) (yes, I do keyRelease as well -> I've tried a bunch of stuff)...

View Replies View Related

Swing/AWT/SWT :: Using JFrame Class In GUI Designing

Jul 16, 2014

I have one question that suppose I am designing a Swing applications and I am using JFrame as Top level container.

So what is best

1)first Extends that class like

public class A Extends JFrame
{
//Do all stuff with Top Level container with gui
}

2)Or design like this from this source

[URL] ....

package components;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* TopLevelDemo.java requires no other files. */
public class TopLevelDemo {
/**
* Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.

[Code] .....

View Replies View Related

Drag And Drop Using Robot Class

Jun 4, 2014

Is it possible to do drag and drop using robot class instead of using TransferHandler class?

View Replies View Related

Designing Jar File Where Access Of Certain Database Provided Through API

Jan 30, 2015

I'm given a task to generate an API (a jar file) where the access of a certain database is provided through the API. basic functionality: Client sends a query through the API to server and the Server responds with data.Since its and API, do I have to implement the code or is it enough if i gave just interfaces? what are the OOP concepts to focus on when designing a good API.

View Replies View Related

Coding A Robot To Follow A Line In Eclipse?

Mar 11, 2014

I have a serious issue with getting this robot to follow a line?

View Replies View Related

How To Make Resizable Screencapture Using Robot In Java

May 9, 2015

I am new to java. I am trying to make a simple screencapture and display program.

I am using robot class to capture a particular portion of the screen and display it in a separate frame.

However I need to be able to resize the area of screencapture. I searched but I dint find any solution wherein I can do so.

I am using this command for capturing the screen

But I couldn't find a way to make the rectangle re-sizable.

Java Code:

BufferedImage buff = robot.createScreenCapture(new Rectangle(0,0,1300,750)); // x-coord, y-coord, width, height mh_sh_highlight_all('java');

View Replies View Related

Program To Simulate Operation Of Simple Robot

Apr 26, 2015

Write a program to simulate the operation of a simple robot. The robot moves in four directions: Forward, backwawrd, left, and right. The job of the robot is to move items and place it in the right slots in each station. There are 8 stations plus the pickup station. Pick up station is the initial start where the robot picks the items. 8 items can be placed on each station. The nearest station must be filled before placing items on the next station. The items are marked with identification or serial numbers. The items with odd serial number go to the right and items with even number go to the eft. The last slot, number 7 is reserved for light items which are less than 80kg. The serial number is a five digit number, the MSB digit 5 indicates that the product must be placed in the fifth station which is keeping the product at 20 degree F.

View Replies View Related

Designing Media Player - Program Cannot Play Any Song

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

Servlets :: Designing A Secure / Standard Login System In J2EE

Jul 29, 2014

Things in mind while designing a secure, standard login system in J2EE . Code snippets ....

View Replies View Related

Opoly Game - Goal Of The Game Is To Reach Or Exceed Reward Value 1000

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

Tic Tac Toe Game - Random Number Generator And Two Dimensional Arrays For Game Board

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

Guessing Game - How To Reset Random Number When User Reset Game

Oct 2, 2014

I tried this program, its guessing game. Where program decide 1 number and user will guess number. I am getting 1 problem. When user want to play game again.the random number remain same. So where i can put reset random in code..? And 1 more question if I want to write driver code for this. What should i transfer to driver code.

import java.util.Random;
import java.util.Scanner;
public class GuessGame {
public static void main(String args[])
{
String choice="y";

[Code] ......

View Replies View Related

Moving A Map In A Game

Jul 22, 2014

I've been at this for a while and I would like to make the Camera in my game follow the player and I know the way to do this would be to move the map and not the player. How would I do this if my map is rendered from a text file using for loops. Here is my code for the map.

package Game;
import java.awt.Graphics;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Map {

[Code] .....

View Replies View Related

Getting TIE In Connect 4 Game?

Oct 20, 2014

I have compiled and coded the whole thing, but the TIE function when no one wins, isn't popping up. I'm not sure why but here is my code;

import java.applet.AudioClip;
import java.awt.*;
import javax.imageio.ImageIO;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;

[code]....

The TIE doesn't pop up, that is all the errors i have, though there is no error messages.

View Replies View Related

How To Add A Scorekeeper For Game

Apr 3, 2014

I am creating a simple AirHockey game in Eclipse Java Jframe. I was just wondering how it is i add a score keeper to my game. for example if player 1 scores a goal 1 is added onto there score at the top.

View Replies View Related

Tic Tac Toe Game Using While Statements

Oct 23, 2014

import java.util.Scanner;
public class TicTacToe {
public static void main(String[] args) {
//Create scanner
Scanner in = new Scanner(System.in);
//Declare variables to hold the board

[Code] ....

I need to create a while statement for random computer moves.

View Replies View Related

Tic Tac Toe Game Based On GUI

Apr 26, 2014

My instructor told me to make game from java but based on GUI. And I thought about it, I want to make Tic Tac Toe (X-O) game.

View Replies View Related

KeyBindings For A Game

Jan 26, 2014

I'm making a game which lets the player move around with arrow keys, but my KeyListeners are working less-than-satisfactorily. I googled this and I found that I should use KeyBindings.

1) Right now I have booleans for each key used in the game. When a key is pressed, the boolean is set to true, and set to false when it is released. In the ActionListener for the Timer I have, I then check if each is pressed or not, and do the corresponding action. I do this so that movement is smooth.If I was to use KeyBindings, would I use the same technique, or would I just do the action in their Action?

2) How do I do it? From the example I thought was most useful, this is my guess: (this code would be in a JPanel)

Java Code:

this.getInputMap().put( KeyStroke.getKeyStroke( "ENTER" ) , "doEnterAction" );
this.getActionMap().put( "doEnterAction" , EnterAction );
static class EnterAction extends AbstractAction
{
public void actionPerformed( ActionEvent tf )
{
enterKeyIsPressed=true; //If using this method, I would also have a separate InputMapping, ActionMapping,

[code]....

View Replies View Related

Tic Tac Toe Game 2D Array

Apr 13, 2014

I know a lot of people taking beginning java courses have posted questions about creating a tic tac toe game, but here is another one. Below is my code. I can't seem to get the X's and O's to show up on the board or to determine a winner.

import java.util.*;
public class Trial3
{
public static char turn;
public static int count;
public static void main(String[]args)
{
Scanner input=new Scanner(System.in);
char[][]b=new char[3][3];
boolean flag=false;
count=0;

[code]....

View Replies View Related

Race Car Game

Oct 20, 2014

Create another class called Race with a main method. Make some Car objects, and use them in a race.The first race will have 2 cars. The main method only needs 2 local variables, i.e. the 2 Car objects.

-The length of the race is 1000.

-Both cars will start out with a speed of 30.

The race will be implemented as a loop. Each time through the loop:

-Your cars will move to a next location by adding their current speed to their location. (If the speed is 50, and they are at location 200, then change the location to 250.)

-Call out the race (SOPLs) like a NASCAR announcer: Andretti is in the lead at position 365. He is flying at 30 mph!

-Or It's neck and neck with both cars at position 45 or something more creative that you can come up with.

-Each car will increase or decrease their speed randomly each time through the main loop.

-The car that is behind will increase its speed by 2 mph, and the car that is in the lead will decrease its speed by 2 mph. (Tighten the race to make it more exciting.)

-The loop will continue until one of the cars is declared to be the winner.

This is my code so far.

public class RaceCarsMain {
public static void main(String[] args) {

int length = 0;

Cars c = new Cars("Andretti", 30);
Cars c2 = new Cars("Fiviotini", 30);
while (c.getLocation() < 1000){
length++;
c.randomSpeedChange();
c.accelerate(2);
c.deaccelerate(2);
c.locationchange();

[code]....

I have been able to print out the first car "Andretti" until its location reaches 1000, but the 2nd car I have not being able to print out the change of speed and change of location.how to proceed and making the 2nd car do the same, do I have to create another class? or how can i use the Cars class to do it for both.

View Replies View Related

2D Game Tile

Dec 16, 2014

When the tile loads it loads at the side where i wanted it to be and when my character falls down the image/tile stretches to the collision and stops. looks like this stretches.jpg

The character codes:
error.jpg

And for the Level:
error2.jpg

View Replies View Related

Connect Four Game

Nov 25, 2014

Our assignment is to make a version of the classic 'Connect Four' game, where we need to construct a GUI that shows the current state of the game and instead of having a winner once a player has four chips in a row, the game needs to continue until no chips can be placed anymore.We currently get stuck in the GUI part. Running it right now results in a board with empty spaces only. Also after choosing a column to place, the board remains empty.

Our question: How do we get the board filled with the right color of chips at the right place?We know the 'ArcsPanel'-class (almost at the bottom of the code) is wrong, but we don't know what to do to make it right.

Main class 'ConnectPanel':

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;

[code]....

At the moment, only the colors white, red and blue are used. This is purely for finding out how to work in general.

View Replies View Related

How To Get Sound To Import It To Game

Apr 7, 2015

how to make a simple game. I am having trouble when it comes to adding sound though. It tells me to do this:

package net.game.Game;
 
import java.applet.Applet;
import java.applet.AudioClip;
 public class Sound {
public static final AudioClip BALL = Applet.newAudioClip(Sound.class.getResource("ball.wav"));
public static final AudioClip GAMEOVER = Applet.newAudioClip(Sound.class.getResource("gameover.wav"));
public static final AudioClip BACK = Applet.newAudioClip(Sound.class.getResource("back.wav"));
}

What this does is it gets the sound file then gives it a name(BALL=ball.wav GAMEOVER=gameover.wav ect..) and then there is other code in other classes that call the sound so it will run but it keeps giving me an error and I don't know what to do. How can I get it to import the sound? Here is the error.

PHP Code:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at net.game.Game.stuff.<init>(stuff.java:35)
    at net.game.Game.stuff.main(stuff.java:62)
Caused by: java.lang.NullPointerException
    at sun.applet.AppletAudioClip.<init>(Unknown Source)
    at java.applet.Applet.newAudioClip(Unknown Source)
    at net.game.Game.Sound.<clinit>(Sound.java:7)
    ... 2 more 

View Replies View Related







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