Errormessage return if value 1 value 1000 joptionpane

Info icon This preview shows pages 3–7. Sign up to view the full content.

View Full Document Right Arrow Icon
ERROR_MESSAGE ); return ; } if ((value < 1) || (value > 1000)) { JOptionPane. showMessageDialog ( null , "Number must be > 0 and < 1000: " + value, "" , JOptionPane. ERROR_MESSAGE ); return ; } int color = thisGame .makeGuess(value); if (color == -1) { JOptionPane. showMessageDialog ( null , "You Guessed The Number " + value, "" , JOptionPane. INFORMATION_MESSAGE ); textGuess .setText( "" ); labHigher .setVisible( false ); labLower .setVisible( false ); textGuess .setEnabled( false ); butStart .setEnabled( true ); textGuess .getParent().setBackground( baseColor ); this .paint( this .getGraphics()); return ; } if (color < 0) { labHigher .setVisible( true ); labLower .setVisible( false );
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
} else { labHigher .setVisible( false ); labLower .setVisible( true ); } textGuess .getParent().setBackground( new Color(Math. abs (color))); this .paint( this .getGraphics()); return ; } System. out .println(e.getActionCommand()); } }
Image of page 4
import java.io.*; import java.util .*; public class TextFileIO { public static void main(String[] args) throws Exception { File fileOne = new File( "numbers.dat" ); fileOne.delete(); File newFile = new File( "numbers.dat" ); newFile.createNewFile(); PrintWriter writer = new PrintWriter( new FileWriter( "numbers.dat" )); for ( int i = 1; i <= 100; i++) { if (i % 2 == 0) {
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
writer.print(i + "," ); } } writer.close(); FileInputStream fileStream = new FileInputStream( "numbers.dat" ); DataInputStream in = new DataInputStream(fileStream); BufferedReader reader = new BufferedReader( new InputStreamReader(in)); System. out .println(reader.readLine()); reader.close(); PrintWriter writer2 = new PrintWriter( new FileWriter( "numbers.dat" )); for ( int i = 1; i <= 100; i++) { if (i % 2 == 1) { writer2.print(i + "," ); } } writer2.close(); FileInputStream fileStream2 = new FileInputStream( "numbers.dat" ); DataInputStream in2 = new DataInputStream(fileStream2); BufferedReader reader2 = new BufferedReader( new InputStreamReader(in2)); System. out .println(reader2.readLine()); reader.close(); } }
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern