954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Message won't show

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?

chiiqui
Junior Poster
107 posts since Sep 2011
Reputation Points: 10
Solved Threads: 3
 

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

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 
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
chiiqui
Junior Poster
107 posts since Sep 2011
Reputation Points: 10
Solved Threads: 3
 

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

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

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!

chiiqui
Junior Poster
107 posts since Sep 2011
Reputation Points: 10
Solved Threads: 3
 

I suspect that 27 "null" messages were printed.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 
I suspect that 27 "null" messages were printed.


No, no results are showing thats it lol

chiiqui
Junior Poster
107 posts since Sep 2011
Reputation Points: 10
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: