Results 1 to 5 of 5
Thread: need help with method
- 04-01-2011, 07:51 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 19
- Rep Power
- 0
need help with method
In this method which is part of a bigger program, it is not sending the information back from where it is being called the way that I want it :
I cant figure out how to get it so it prints out:Java Code:private void displayCurrentState(int currentScoreU, int currentScoreC, boolean stayU, boolean stayC) { displayDashes(); displayDashes(); System.out.print("- User score:" + currentScoreU); if(stayU == true){ System.out.println(". User has stayed."); } if(stayU == false){ System.out.println(); } System.out.print("- Computer score:" + currentScoreC); if(stayC == true){ System.out.println(". Computer has stayed."); } if(stayC == false){ System.out.println(); }
1.
----------------------------------------------
----------------------------------------------
- User score: 18
- Computer score: 17
----------------------------------------------
----------------------------------------------
2.
----------------------------------------------
----------------------------------------------
- User score: 16
- Computer score: 19. Computer has stayed.
----------------------------------------------
----------------------------------------------
3.
----------------------------------------------
----------------------------------------------
- User score: 18. Computer has stayed.
- Computer score: 17
----------------------------------------------
----------------------------------------------
the methods, this method is asking for are doing most of the jobs I just need to lay it out correctly but right now all that is being printed out is this: (notice the placement of the "2." and "3." are placed wrong and some of the dash's are missing)
1.
----------------------------------------------
----------------------------------------------
- User score: 18
- Computer score: 17
2.
----------------------------------------------
----------------------------------------------
- User score: 16
- Computer score: 19. Computer has stayed.
3.
----------------------------------------------
----------------------------------------------
- User score: 18. Computer has stayed.
- Computer score: 17
the code this is all sent to looks like this (this code does not need to be edited):
Can someone show me how the method I'm trying to fix should look and where I'm going wrong? Much thanks :DJava Code:private void test01() { System.out.println("Your output:"); System.out.println("1."); displayCurrentState(18, 17, false, false); System.out.println("2."); displayCurrentState(16, 19, false, true); System.out.println("3."); displayCurrentState(21, 17, true, false);Last edited by shazakala; 04-01-2011 at 08:23 AM.
- 04-01-2011, 08:08 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
sorry I still haven't figured out how to show the code nicely
You put [code] at the start of the code and [/code] at the end. I think you can edit your post to do this - but make sure the indentation is correct if you edit the post.
Close! But it should be [/code] at the end.Last edited by pbrockway2; 04-01-2011 at 08:14 AM.
- 04-01-2011, 08:13 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 19
- Rep Power
- 0
thanks thats one problem out of the way ^.^
- 04-01-2011, 08:15 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
The output you say you get is exactly what you say you should be getting (unless I am missing something...) And neither can possibly be produced by the code you posted.
- 04-01-2011, 11:28 AM #5
Member
- Join Date
- Mar 2011
- Posts
- 19
- Rep Power
- 0
Similar Threads
-
Declaring a method inside a method: Runnable?
By africanhacker in forum New To JavaReplies: 8Last Post: 03-23-2011, 04:30 AM -
Turning Recursion Method into Iterative method
By mattakuevan in forum New To JavaReplies: 9Last Post: 06-15-2010, 06:46 AM -
method not abstract, does not override actionperformed method.
By Theman in forum New To JavaReplies: 2Last Post: 03-26-2010, 05:12 PM -
ArrayLists compareTo method, equals method
By random0munky in forum New To JavaReplies: 2Last Post: 10-26-2009, 07:20 PM -
cannot call private method from static method
By jon80 in forum New To JavaReplies: 3Last Post: 05-07-2008, 08:37 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks