Black Jack Game - Initiated Object Returning Null

Nov 7, 2014

I've been assigned to create a Black Jack game with a gui. In this game I've created a seperate Player and Dealer class, and both initiated them, however when I try to call a Player object in a certain way I get a null pointer reference. (It should be noted that the Player object is an array)

public void runGame(){
while(running){
while(dealer.getPoints() <=19){
int count=0;

[Code] .....

And this is how I've initilized the Player class in the constructor

Player[] players = new Player[numberofplayers];
for(int i=0; i<numberofplayers; i++){
players[i] = new Player(i);
players[i].setDeck(d1);
gui.add(players[i].getPanel());
}

What I don't get is if I change players[i] to dealer, it works fine.

View Replies


ADVERTISEMENT

Created Tree Lemur Object - Returning Null Consistently From Methods

May 24, 2015

The question pretty much says it all, but I tasked myself with creating a program about lemurs. There are multiple class files in this program. In the below code snippet, I have my TreeLemur.class which extends to the Lemur.class which extends to the Mammal.class. However, when I create a Tree Lemur object in the main program, it is returning null consistently from certain methods. What am I doing wrong here?

TreeLemur.class :

public class TreeLemur extends Lemur {
private String groupSize;
private String diet;
private String fur;
public void setGroupSize() {
groupSize = "
Group Size: Large";
}

[Code]...

As of yet, I'm just trying to get Tree Lemur working properly to continue with creating the other if-branches within the main program.

View Replies View Related

Why Is Method Returning Null

Sep 25, 2014

I am working on a project which manages an airport's airplanes and flights based on user input. The method printFlights() - lines 133-134 - is returning null and I can't figure out why. The method is supposed to print information about each flight. The logic is identical to the printPlanes() method which is working successfully.

View Replies View Related

GetNextMailItem Keeps Returning Null

Jun 16, 2014

When I try to getNextMailItem,it keeps returning null.Why?

public class MailServer
{
// Storage for the arbitrary number of mail items to be stored
// on the server.
private HashMap<String,ArrayList<MailItem>> mailbox;
/**
* Construct a mail server.
*/
public MailServer()

[Code] .....

View Replies View Related

FileReader - Returning Null

Jan 12, 2014

I'm following a tutorial and I can't work out why the version that I have written is returning null when reading the text file...?

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class AppReadFileFileReader {
public static void main(String[] args) {
File file = new File("test.txt");
BufferedReader br = null;

[Code] ...

I can't see any difference in the code though, and the files being found in order for the null to appear... :?

the text file is within the Java project, and just has three lines :

line one
line two
line three

That's all it say..... But all my program returns is the work 'null'

View Replies View Related

Method Is Not Returning Array - Null Error

May 18, 2015

I am trying to return an array and I keep getting a null error. The below class sets the material numbers into an array and should return that array if called :

public class Jobs {
private int[] materialsNumber;
//change to parts and create another class that gets the materials for the parts
 public int[] job1() {
materialsNumber[0] = 11960120;

[Code] ....

I later try to call the method. The program executes but stops after I println "test in loop"

public class PurchaseOrdersToParts {
 private Jobs job = new Jobs();
 int[] getPartsForPurchaseOrder(BigDecimal purchaseOrder) {
 System.out.println("inside getparts");
 BigDecimal testNum = new BigDecimal(123.0);
 
[Code] ....

This is the method that is calling the method in the GenerateOrdersToParts class

private PurchaseOrdersToParts purchaseOrdersToParts = new PurchaseOrdersToParts();
 @Inject
PoRepository poRepository;
public GenerateShopJobTickets() {
 
[Code] .....

View Replies View Related

Linked List Sort - ToString Returning Null

May 22, 2014

import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.lang.Comparable;
import java.util.*;
import java.lang.*;
public class MyLinkedListSort {

[Code] .....

Output is :

name is nulland salary is0
name is nulland salary is0
name is nulland salary is0
name is nulland salary is0

Expected output :

Name is Crish Salary: 2000
Name is Tom Salary: 2400
Name is Ram Salary: 3000
Name is John Salary: 6000

Where i going wrong

View Replies View Related

Returning Text From A String Object?

Feb 19, 2015

I run a bash command and save the output as a string object

String str1 = "" +getLastOutput();

str1 would look like this: abcd efgh lkmn xsds

In this string ( str1) i need to check three separate words are there.

If i have an if statement with str1.contains("xyz") && str1.contains("lkmn") &&str1.contains("zzzzzzzzzzzz")

How can i get the one that is not there returned to the screen? so i can use elsewhere?

View Replies View Related

Returning Object After Try-Catch Statements

May 5, 2014

So I'm pretty sure this is correct, as it follows most examples I can find online, but I keep getting an error that my return variable cannot be resolved. The error is on the return conn; statement. It says conn cannot be resolved. If I place it above within the try block it allows it but then I receive an error saying the method getDBConnection must return type Connection.

import java.sql.*;
public Connection getDBConnection() {
try {
Class.forName("org.sqlite.JDBC");
String path = "jdbc:sqlite::resource:project.db";

[Code] .....

I don't want to create this method. Basically I want to connect to the database in the main program, but I do want methods that can access the DB too. But however I place it, it doesn't let me touch any of the DB variables outside of the Try block.

View Replies View Related

Returning Object That Has Been Removed Using Remove Method

Nov 18, 2014

So i have used the "remove()" method in conjunction with an iterator to remove an object from a HashSet in my program, and part of my exercise requires me to return said object. What I can do to return an object that has been removed using "remove()" method?

View Replies View Related

EJB / EE :: Create Stateless Bean That Instead Of Returning A String Returns Object

Jul 31, 2014

I'm training myself with the EJB 3 technology. I would like to create a stateless bean that instead of returning a String, it returns an object. I tried in the same way I did with the first exercise, but I'm getting several errors.

View Replies View Related

What Is The Length Of A Null Array Object

Feb 21, 2014

I tried the following and it gives me null pointer exception. I just want to verify if what is the actual value of a length of an array?

Object [] obj = null;
System.out.println("length:" + obj.length);

View Replies View Related

How To Create Object To Be Null If Class Constructor Parameter Is Int

Mar 8, 2015

I have a class of Date with a constructor with 3 parameters in it. Those 3 parameters are int data type just to enter month, year, day.

I have another class called Author which has a constructor of Date diedDate; as a parameter passing to the Author constructor.

I was asked to call the Date parameter is null, call the default constructor but I thought for the Date parameter I could only enter something like 0,0,0 instead of typing in null, null, null because null is for String data type isn't it?

View Replies View Related

Java Convert String Of XML To Document Object Is Null All The Time

Apr 14, 2014

I am trying to parse a XML string into `org.w3c.dom.Document` object.

I have looked at solutions provided [here](xml - How to convert String to DOM Document object in java? - Stack Overflow), [here](How to create a XML object from String in Java? - Stack Overflow) and a few other blogs that give a variation of the same solution. But the `Document` object's #Document variable is always null and nothing gets parsed.

Here is the XML

XMLMappingValidator v = new XMLMappingValidator("<?xml version="1.0" encoding="utf-8"?>
" +
"<mapping>
" +
"<container>
" +
"<source-container>c:stem.csv</source-container>

[Code] ....

When I call
**v.getXML().toString()**
I get
`[#document: null]`

Clearly, the parse is failing. But I don't understand why.

View Replies View Related

Web Services :: GregorianCalendar Object Passed As Null In Request - JAX-WS On Websphere

Jan 20, 2015

I created the WSDL first in RSA and then created the java bean skelaton from the WSDL. There are a couple of dateTime fields in the WSDL that are created as GregorianCalendar objects.

When I test with SOAPui and the date fields are passed correctly, everything works great. But when there is an invalid date format or anything else in the SOAP request, instead of returning a Conversion exception or some other validation exception, the field is passed as a null to the request object in the SOAP IMPL. Should't this return an exception?

Sample requests inputs:
<endTimeStamp>2014-01-28T01:30:14.474Z</endTimeStamp> - Date
<endTimeStamp>06-FEB-14 01.51.00.000000000 AM</endTimeStamp> - Null
<endTimeStamp>Any other string be it a date or not.</endTimeStamp> - Null

[Code].....

View Replies View Related

Java Convert String Of XML To Document Object Is Null All The Time

Apr 15, 2014

I am trying to parse a XML string into `org.w3c.dom.Document` object.

I have looked at solutions provided [here](xml - How to convert String to DOM Document object in java? - Stack Overflow), [here](How to create a XML object from String in Java? - Stack Overflow) and a few other blogs that give a variation of the same solution. But the `Document` object's #Document variable is always null and nothing gets parsed.

Here is the XML

Java Code:

XMLMappingValidator v = new XMLMappingValidator("<?xml version="1.0" encoding="utf-8"?>
" +
"<mapping>
" +
"<container>
" +
"<source-container>c:stem.csv</source-container>

[Code] .....

When I call Java Code: **v.getXML().toString()** mh_sh_highlight_all('java');

I get Java Code: `[#document: null]` mh_sh_highlight_all('java');

Clearly, the parse is failing. But I don't understand why.

View Replies View Related

Which Method Is Used While Passing Or Returning A Object From The Native Method

Mar 5, 2014

Which method is used while passing or returning a java object from the native method?

View Replies View Related

Make A Screen Black For A Buffered Image

Jan 10, 2015

I tried to make a buffered screen image that constantly refreshed an image (a black screen) however it does not seem to be working.

Java Code: import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;

[code]....

View Replies View Related

Generating Picture - Black And White Sketch

Nov 19, 2014

I'm stuck with a problem. The code below generates a coloured image.

//Setting the size of the graphics window
final int WINDOW_DIMENSION = 200;
final int SIZE_FACTOR = 3;
EasyGraphics generate = new EasyGraphics(WINDOW_DIMENSION*SIZE_FACTOR,WINDOW_DIMENSION*SIZE_FACTOR);
 
//Constructing the arrays
char[][] firstArray = new char[WINDOW_DIMENSION][WINDOW_DIMENSION];
char[] secondArray = scan.toCharArray();
 
[Code] ...

What I would like to do is generate a picture which is mostly white but the colour boundaries of the original picture are in black. I tried using the code below but it doesn't produce what I wanted.

for (int a = 1; a < WINDOW_DIMENSION; a++) {
for (int b = 1; b < WINDOW_DIMENSION; b++) {
generate.setColor(0,0,0);
if(firstArray[a][b]!=firstArray[a-1][b] || firstArray[a][b]!=firstArray[a][b-1])
generate.setColor(255,255,255);
generate.plot(a,b);
}
}

View Replies View Related

When Running A GUI It Is Possible To Stop Black System Window From Opening

Oct 20, 2014

When running a Java GUI is it possible to stop black system window from opening as we'll

View Replies View Related

Graphics In Game - How To Draw Object Or Get It Into The Frame

Apr 23, 2014

I am trying to create this snake and input it into the next window that is opened when the play button is pushed but how to draw this snake or get him into the frame and i have looked all over google.

import javax.swing.*;
import javax.swing.Box.Filler;
import java.awt.*;
import java.awt.event.*;
public class SnakeObject extends JFrame
{
public SnakeObject()

[Code] ....

View Replies View Related

Timed Object Generation For Guitar Hero Game

May 22, 2014

I want to generate a new tile every 1,5,10,15 (please check the code to gain an understanding of where I'm going) the session last for 4m :20 sec, I need using the date package, I tried using the sleep method however I don't want to pause the whole thread, so I need setting up the time aspect of the key generation (assume all other code works).

Java Code:

import info.gridworld.actor.*;
import info.gridworld.grid.*;
import java.awt.*;
import java.util.*;
//importations, just in case you were wondering
//locations and actor world are set up
//assume all other code works

[Code] ....

I'm using grid world to set up the locations, the tiles are actors that move south every turn

View Replies View Related

Object Orientation Logic For Tic Tac Toe Game - Return Winner Or Tie

Jan 28, 2014

I need to find the Winner using Object Orientation logic I have my old logic from my Tic Tac Toe game but it is not Object Orientated. So I want to convert it and add that code to my GUI Tic Tac Toe. I need to return a winner or tie.

View Replies View Related

Swing/AWT/SWT :: JTable Cell Renderer Causing Program To Go Black When Minimized

Aug 25, 2014

I'm making a program that selects classes from a database via a jcombo box and then populates a time table with the class times.

I've used a custom cellrenderer that extends DefaultTableCellRenderer to text wrap the information and change the background of the cells.

It works but when i minimize the program it goes all black and if I double click I get a new JTextArea opening up on the timetable and when I minimize the program and go to open it again i get an "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException" and the cell render seems to be called again even though i haven't rerun the program.

This is the cell renderer that I built

public class TimesTableCellRenderer extends DefaultTableCellRenderer {
private int minHeight = -1;
private final JLabel label = new JLabel();
private final JTextArea textArea = new JTextArea();
public TimesTableCellRenderer(){
super();
textArea.setLineWrap(true);

[Code] ....

View Replies View Related

2-dimensional Array - Print Black Image Depending On Number Of Rows And Columns

Nov 21, 2014

I wrote this code which print a black image depends on the number of rows and columns you give it

public class BlackImg {
private Mycolor[][] colorArr; //Mycolor is a class i wrote that represents colors.
// no need for showing the class here.
// so i created here an array of type Mycolor, for example:
// { {(255,255,255), {(127,127,0)} }

[Code] .....

my problem is that my output comes good except the last line ,

Output:
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
BlackImg@1db9742 //what is this line , why does it showing up ?

View Replies View Related

Null Pointer Access Variable Can Only Be Null At This Location

Apr 16, 2014

I'm getting an error on line 137 and all it is rsmd = rs.getMetaData();The error happens only after I press a JButton and it is

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionat softwareDesign.createAccount.actionPerformed(createAccount.java:137)

There is a lot more to it but that has nothing to do with my code it's just the stuff with Eclipse anyway I want to know how do I fix this problem?

View Replies View Related







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