public class Product {
private boolean isShortWarranty;
private String category;
public Product(boolean isShortWarranty,String category) {
this.isShortWarranty = isShortWarranty;
this.category = category;
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String category = "";
while (category.length() == 0) {
System.out.println("Chose the category:\nTV\nPhones\nGames");
category = in.nextLine();
switch (category) {
case "TV":
case "Phones":
case "Games":
System.out.println("Category accepted.");
break;
default:
category = "";
System.out.println("Invalid category. Try again.");
}
}
System.out.println("1-Applies a six-month product warranty.\n" +
"Any other key applies a two-year warranty: ");
String warranty = in.nextLine();
Product product = new Product(warranty.equals("1"), category);
System.out.println("The product details have been successfully saved");
}
}
Comments
Leave a comment