document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*Write a class of COMPASS member.
  2. Attributes: name, member ID, gender and IC no.
  3.     use default constructor with no parameter
  4.     use mutator that set all variables
  5.     write all the accessor
  6.     write a toString() method
  7.     write another method to check age is 20 or greater and return true. otherwise return false
  8. In the main program, ask for data input from user. Display each data.
  9. If the user are 20 years old or greater and a male, display "You can play games in the Lab.".
  10. otherwise, display "You can\'t play games in the Lab."
  11. */
  12. import javax.swing.*;
  13. public class COMPASSDataInput{
  14.     public static void main(String[] args){
  15.     COMPASSMember Member = new COMPASSMember(); // constructor - > DONT FORGET. if normal construct, must after INPUT
  16.     String name,ID,gender,IC;
  17.     name = JOptionPane.showInputDialog(null,"Enter your name.");
  18.     ID = JOptionPane.showInputDialog(null,"Enter your Member ID.");
  19.     gender = JOptionPane.showInputDialog(null,"Enter your gender[male/female].");
  20.     IC = JOptionPane.showInputDialog(null,"Enter your IC no[990101130101].");
  21.     Member.setData(name,ID,gender,IC);
  22.     JOptionPane.showMessageDialog(null,Member);
  23.     //System.out.println(Member.getAge());
  24.     if ((Member.getGender()).equalsIgnoreCase("Male")){
  25.         if (Member.checkAge20())
  26.         JOptionPane.showMessageDialog(null,"You can play games in the Lab.");
  27.     }
  28.     else
  29.         JOptionPane.showMessageDialog(null,"You can NOT play games in the Lab.");
  30.     }
  31. }
');