Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-10-2008, 07:46 AM
dc2acgsr99's Avatar
Member
 
Join Date: Jan 2008
Location: Pittsburgh
Posts: 26
dc2acgsr99 is on a distinguished road
Send a message via AIM to dc2acgsr99
Code
No real point to this thread, just wanted to show off where my baby steps have gotten me thus far


Quote:
/*
* Filename: kthMLab3.java
* Created: 01/30/2008 by Kevin H
* Modified: 02/06/2008 by Kevin H
* Purpose: Display various objects
*/

public class kthMLab3 //start of class kthMLab3

{

public static void main(String[] args) //start of main method

{

xObject();

spacer();
spacer();

diamondObject();

spacer();
spacer();

rocketObject();

} //end of main method

public static void xObject() //start x

{

downarrow();
uparrow();

} //end x

public static void diamondObject() //start diamond

{

xpiece();
uparrow();
middlepiece();
downarrow();
xpiece();

} //end diamond

public static void rocketObject() //start rocket

{

xpiece();
uparrow();
verticallines();
crossline();
rockettail();
rocketexhaust();

} //end rocket

public static void uparrow() //start of uparrow

{

System.out.println(" |||");
System.out.println(" |||||");
System.out.println(" |||||||");
System.out.println(" |||||||||");
System.out.println(" |||||||||||");
System.out.println(" |||||||||||||");
System.out.println(" |||||||||||||||");
System.out.println(" |||||||||||||||||");
System.out.println(" |||||||||||||||||||");
System.out.println(" |||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");

} //end of uparrow

public static void downarrow() //start of downarrow

{

System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" |||||||||||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||||");
System.out.println(" |||||||||||||||||||||");
System.out.println(" |||||||||||||||||||");
System.out.println(" |||||||||||||||||");
System.out.println(" |||||||||||||||");
System.out.println(" |||||||||||||");
System.out.println(" |||||||||||");
System.out.println(" |||||||||");
System.out.println(" |||||||");
System.out.println(" |||||");
System.out.println(" |||");

} //end of downarrow

public static void crossline() //start of crossline

{

System.out.println(" =============================================");
System.out.println(" =============================================");
System.out.println(" =============================================");
System.out.println(" =============================================");
System.out.println(" =============================================");
System.out.println(" =============================================");

} //end of crossline

public static void verticallines() //start of verticallines

{

System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");

} //end of verticallines

public static void rocketexhaust() //start of rocketexhaust

{

System.out.println(" |*******************************************|");
System.out.println(" |************************||***************|");
System.out.println(" |************||********| |*************|");
System.out.println(" |**********| |******| |***********||");
System.out.println(" |********| ||****|| |**********|");
System.out.println(" |********| |****| |********|");
System.out.println(" |********| |**| ||******||");
System.out.println(" |******| |||| |******|");
System.out.println(" ||****|| || |****|");
System.out.println(" |****| ||**||");
System.out.println(" |**| |**|");
System.out.println(" |||| |||");
System.out.println(" || |");

} //end of rocketexhaust

public static void middlepiece () //start of middlepiece

{

System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println("||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");

} //end of middlepiece

public static void rockettail() //start of rockettail

{

System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" ||||||||||||||| |||||||||||||||");
System.out.println(" =============================================");
System.out.println(" =============================================");

} //end of rockettail

public static void spacer() //start of spacer

{

System.out.println();
System.out.println();

} //end of spacer

public static void xpiece() //start or xpiece

{
System.out.println(" |");

} //end of xpiece

} //end of class kthMLab3
Apparently we are moving on up from seeing our work in the general output window soon, so thats exciting. But yeah that where my java skills currently stand.
__________________
Hey I'm still learning... Thats my story and I'm sticking to it
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-10-2008, 10:36 AM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Very good
Hello dc2acgsr99

I glad that you are making progress. Try to self study loops and if-statements. With that, you can really improve on this code. Search the forums and the internet and ask when you get stuck at Java Forums.

Good luck!
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-12-2008, 12:46 AM
dc2acgsr99's Avatar
Member
 
Join Date: Jan 2008
Location: Pittsburgh
Posts: 26
dc2acgsr99 is on a distinguished road
Send a message via AIM to dc2acgsr99
Tim you must have the power to see the future my friend because my question pertains to just that, the "if" statements and so forth. Specifically the code below is strikingly similar to the one posted above with modifications, now everything complies and executes just fine but... I must have the section in red there or it will show an error when the cancel button is pressed, but when it is there the D, X and R do not show their image in the general output window... But to add to it I do not think the "else" statements are being used correctly as no matter what letter I input into the "JOptionPane.showInputDialog" it shows the "Please enter a D, X or R" message, even if it is the right letter and it shows the image... Ideas, views, suggestions, opinions?

Code:
import javax.swing.JOptionPane; public class kthMiniLab4 //start class { public static void main (String[] args) //start main { progra(); System.exit (0); } //end main public static void progra() //start progra { String response; response = JOptionPane.showInputDialog ( "Type a D for a Diamond, an X for an X and a R for a Rocket." ); { //cancel if (response == null) JOptionPane.showMessageDialog(null, "Quitter!!"); System.exit (0); } //cancel { //diamond if (response.equals("D")||(response.equals("d"))) diamondObject(); else JOptionPane.showMessageDialog (null, "Please enter a D, X or R"); } //diamond { //the X if (response.equals("X")||(response.equals("x"))) xObject(); else JOptionPane.showMessageDialog (null, "Please enter a D, X or R"); } //the X { //rocket if (response.equals("R")||(response.equals("r"))) rocketObject(); else JOptionPane.showMessageDialog (null, "Please enter a D, X or R"); } //rocket } //end progra public static void xObject() //start x { downarrow(); uparrow(); } //end x public static void diamondObject() //start diamond { xpiece(); uparrow(); middlepiece(); downarrow(); xpiece(); } //end diamond public static void rocketObject() //start rocket { xpiece(); uparrow(); verticallines(); crossline(); rockettail(); rocketexhaust(); } //end rocket public static void uparrow() //start of uparrow { System.out.println(" |||"); System.out.println(" |||||"); System.out.println(" |||||||"); System.out.println(" |||||||||"); System.out.println(" |||||||||||"); System.out.println(" |||||||||||||"); System.out.println(" |||||||||||||||"); System.out.println(" |||||||||||||||||"); System.out.println(" |||||||||||||||||||"); System.out.println(" |||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); } //end of uparrow public static void downarrow() //start of downarrow { System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" |||||||||||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||||"); System.out.println(" |||||||||||||||||||||"); System.out.println(" |||||||||||||||||||"); System.out.println(" |||||||||||||||||"); System.out.println(" |||||||||||||||"); System.out.println(" |||||||||||||"); System.out.println(" |||||||||||"); System.out.println(" |||||||||"); System.out.println(" |||||||"); System.out.println(" |||||"); System.out.println(" |||"); } //end of downarrow public static void crossline() //start of crossline { System.out.println(" ============================================="); System.out.println(" ============================================="); System.out.println(" ============================================="); System.out.println(" ============================================="); System.out.println(" ============================================="); System.out.println(" ============================================="); } //end of crossline public static void verticallines() //start of verticallines { System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); } //end of verticallines public static void rocketexhaust() //start of rocketexhaust { System.out.println(" |*******************************************|"); System.out.println(" |************************||***************|"); System.out.println(" |************||********| |*************|"); System.out.println(" |**********| |******| |***********||"); System.out.println(" |********| ||****|| |**********|"); System.out.println(" |********| |****| |********|"); System.out.println(" |********| |**| ||******||"); System.out.println(" |******| |||| |******|"); System.out.println(" ||****|| || |****|"); System.out.println(" |****| ||**||"); System.out.println(" |**| |**|"); System.out.println(" |||| |||"); System.out.println(" || |"); } //end of rocketexhaust public static void middlepiece () //start of middlepiece { System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println("||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); } //end of middlepiece public static void rockettail() //start of rockettail { System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ||||||||||||||| |||||||||||||||"); System.out.println(" ============================================="); System.out.println(" ============================================="); } //end of rockettail public static void spacer() //start of spacer { System.out.println(); System.out.println(); } //end of spacer public static void xpiece() //start or xpiece { System.out.println(" |"); } //end xpiece } //end class
__________________
Hey I'm still learning... Thats my story and I'm sticking to it
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-13-2008, 06:37 AM
dc2acgsr99's Avatar
Member
 
Join Date: Jan 2008
Location: Pittsburgh
Posts: 26
dc2acgsr99 is on a distinguished road
Send a message via AIM to dc2acgsr99
no takers???
__________________
Hey I'm still learning... Thats my story and I'm sticking to it
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 02-13-2008, 06:45 AM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Nested if-statements
Hello dc2acgsr99

Try nesting your if-statements. For example:
Code:
if (input1){ // Do input 1 } else if (input2){ // Do input 2 } else if (input3) { // Do input 3 } // And so forth
Hope that helps.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help fixing my code.. or non code? MrHuggykins New To Java 1 03-19-2008 11:12 PM
Pls some one to help mi wit this code _nik_ New To Java 3 02-10-2008 03:02 AM
tic tac toe code zoe New To Java 1 07-23-2007 05:36 PM
Need help with my code. stormviper New To Java 0 07-12-2007 04:18 PM
Generating Code Automatically Using Custom code Template In Eclipse JavaForums Eclipse 1 04-26-2007 04:52 PM


All times are GMT +3. The time now is 10:22 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org