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?
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