Vexus

E9

Dec 3rd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. package person;
  2.  
  3. public class Student {
  4.  
  5.         int age = 15;
  6.         String s = "Patrick's age is " + age;
  7.                
  8.        
  9.         int year = 1999;
  10.         String s1 = "Patrick's year is " + year;
  11.                
  12.         {
  13.                 Major Major = new Major();
  14.                 String s = Major.toString();
  15.                      
  16.         }
  17. }
  18.  
  19. package person;
  20.  
  21. public class Instrctor {
  22.  
  23.         int age = 35;
  24.         String s = "Jake's age is " + age;
  25.                
  26.        
  27.         int year = 1984;
  28.         String s1 = "jake's year is " + year;
  29.      
  30.         {
  31.                 Salary Salary = new Salary();
  32.                 String s = Salary.toString();
  33.                    
  34.         }
  35. }
  36.  
  37.  
  38.  
  39.  
  40. public class AnyCorrectChoiceQuestion {
  41.  
  42.         private String text;
  43.          private String answer;
  44.        
  45.        
  46.          public AnyCorrectChoiceQuestion()
  47.          {
  48.          text = "";
  49.          answer = "";
  50.          }
  51.        
  52.        
  53.          public void setText(String questionText)
  54.          {
  55.          text = questionText;
  56.          }
  57.        
  58.        
  59.          public void setAnswer(String correctResponse)
  60.          {
  61.          answer = correctResponse;
  62.          }
  63.        
  64.        
  65.          public boolean checkAnswer(String response)
  66.          {
  67.          return response.equals(answer);
  68.          }
  69.        
  70.        
  71.          public void display()
  72.          {
  73.          System.out.println(text);
  74.          }
  75.        
  76. }
  77.  
  78. import java.util.Scanner;
  79.  
  80.  
  81.  
  82. public class Demo1
  83. {
  84.         public static void main(String[] args)
  85.         {
  86.                 Scanner in = new Scanner(System.in);
  87.                
  88.                 AnyCorrectChoiceQuestion q = new AnyCorrectChoiceQuestion();
  89.                 q.setText("What is 2 + 2?");
  90.                 q.setAnswer("4");
  91.                
  92.                 q.display();
  93.                 System.out.print("4");
  94.                 String response = in.nextLine();
  95.                 String response = null;
  96.                 System.out.println(q.checkAnswer(response));
  97.         }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment