Advertisement
Shavit

P. 75 Ex. 11.3

Jan 26th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class mainCat {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         cat cat;
  12.         Scanner in = new Scanner(System.in);
  13.        
  14.         String name, type;
  15.         boolean water, meow;
  16.        
  17.         System.out.printf("Enter the cat's name: ");
  18.         name = in.next();
  19.        
  20.         while(!name.equals("*"))
  21.         {
  22.             System.out.printf("Enter the cat's type: ");
  23.             type = in.next();
  24.             System.out.printf("Does your cat like to meow? <T or F> ");
  25.             meow = in.next().charAt(0) == 'T' ? true : false;
  26.             System.out.printf("Does your cat like water? <T or F> ");
  27.             water = in.next().charAt(0) == 'T' ? true : false;
  28.            
  29.             cat = new cat(name, type, water, meow);
  30.            
  31.             System.out.printf("%s\n", cat.data());
  32.             System.out.printf("%s\n",  cat.meow());
  33.             System.out.printf(cat.water() ? "I like water!\n" : "I don't like water!\n");
  34.            
  35.             System.out.printf("Enter the cat's name: ");
  36.             name = in.next();
  37.         }
  38.        
  39.         in.close();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement