import java.util.Scanner; class Product { String name; double price; public Product(String name, double price) { this.name = name; this.price = price; } } class Register { public Product inputProduct() { Scanner sc = new Scanner(System.in); System.out.print("Név: "); String name = sc.nextLine(); if (!isGoodName(name)) { System.exit(1); } System.out.print("Ár: "); String priceStr = sc.nextLine(); double price = Double.parseDouble(priceStr); sc.close(); Product product = new Product(name, price); return product; } public boolean isGoodName(String name) { boolean good = true; if (name.length()<1) good = false; if (!name.matches("[a-zA-záéíóöőúüűÁÉÍÓÖŐÚÜŰ]+")) good = false; return good; } public boolean isGoodPrice(double price) { final int m = 3000000; boolean good = true; if (price < 1) good = false; if (price > m) good = false; return good; } } public class App { public static void main(String[] args) throws Exception { Register register = new Register(); Product product = register.inputProduct(); System.out.println(product.name); System.out.println(product.price); } }