Advertisement
sergAccount

Untitled

Oct 18th, 2020
1,671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package game;
  7.  
  8. import javax.swing.JOptionPane;
  9.  
  10. public class Game {
  11.  
  12.     public static void main(String[] args) {        
  13.         // JOptionPane.showInputDialog - метод для показа диалога для ввода информации
  14.         String rez = JOptionPane.showInputDialog(null, "Введите сложность игры от 1 до 7:", "Сложность игры", 1);
  15.         System.out.println("rez=" + rez);
  16.         // используем метод для выполнения преобразования из строки в число (значение типа int)
  17.         int slogn = Integer.parseInt(rez);
  18.         System.out.println("slogn=" + slogn);
  19.         // проверка что число находится в диапозоне от 1 до 7
  20.         // && - логическое И  || - логическое ИЛИ  
  21.         if(slogn>=1 && slogn<=7){
  22.             //System.out.println("OK!");
  23.             new Okno(slogn);
  24.         }
  25.     }        
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement