0
public class GAME {

	
	boolean gamestatus = true;
	
	double amounts[] = {0, 0.01, 0.5, 1, 5, 10, 11, 14, 20, 300, 600, 150,
			13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28 };
	
	Briefcase briefcase[] = new Briefcase[27];
	
	public void casesSetup(){
		for (int i = 0; i < briefcase.length; i++) {
			briefcase[i] = new Briefcase();
			double value = amounts[i];
			briefcase[i].setAmount(value);
			briefcase[i].setFace(i);
		}
	}
	
	public void showCases(){
		
		for (int a = 1; a < briefcase.length; a++) {
			if (briefcase[a] == null) { //skip this block

			} else {
				System.out.print("\t" +briefcase[a].getFace() + " ");
				if (a % 5 == 0) {
					System.out.println();
				}
			}
		}
	}
	public void showMEssage(){
		System.out.println("Butsecks");
	}
	
	public static void main(String[]args){
			GAME dnd = new GAME();
			dnd.showMEssage();
			dnd.showCases();
	}
	
}

why is that the showMEssage() method is showing it's message while showCases(); method cannot?

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by chiiqui
Featured Replies
  • 1

    You need more printlns for debugging. Add a println at line 4 to show the value of a. Add a println before line 2 to show the length of the array Read More

0

Add some printlns to the showCases method to display the values of the variables that control whether it prints or not.

0

Add some printlns to the showCases method to display the values of the variables that control whether it prints or not.

I am trying to print out the faces of my Briefcase object , and there's already printlns on it look

public void showCases(){
		for (int a = 1; a < briefcase.length; a++) {
			if (briefcase[a] == null) { //skip this block

			} else {
				System.out.println("\t" +briefcase[a].getFace() + " ");
				if (a % 5 == 0) {
					System.out.println();
				}
			}
		}
	}
	pub
1

You need more printlns for debugging.

Add a println at line 4 to show the value of a.
Add a println before line 2 to show the length of the array

Edited by NormR1: n/a

0

You need more printlns for debugging.

Add a println at line 4 to show the value of a.
Add a println before line 2 to show the length of the array

Okay, I've Fixed lol, I didn't initiate my objects! Silly me!

0

I suspect that 27 "null" messages were printed.

No, no results are showing thats it lol

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.