一个用JAVA编写的洗澡提醒程序,对话框练习,程序员也可以逗女朋友玩

来源:互联网 发布:苹果如何删除windows 编辑:程序博客网 时间:2024/04/28 01:30
import java.util.*;import java.util.regex.Matcher;import java.util.regex.Pattern;import javax.swing.JOptionPane;public class SecondSample {public static void main(String[] args){String setTime = null;setTime=JOptionPane.showInputDialog(null, "你是打算  hh:mm 去洗澡阿?\n(例如:08:30)");checkInput bb = new checkInput(setTime);int hour=bb.returnHour();int minute=bb.returnMinute();//System.out.println(setTime);while(true){GregorianCalendar d= new GregorianCalendar();if((d.get(Calendar.HOUR_OF_DAY)>=hour) && (d.get(Calendar.MINUTE)>=minute)){remaidWindow ppp=new remaidWindow(d.get(Calendar.HOUR_OF_DAY),d.get(Calendar.MINUTE));JOptionPane.showMessageDialog(null,"已经  "+d.get(Calendar.HOUR_OF_DAY)+":"+d.get(Calendar.MINUTE)+" 了,快给我滚去洗澡", "Now is :", JOptionPane.PLAIN_MESSAGE);ppp.remaidShow();break;}}//ppp.remaidShow();System.exit(0);}}class remaidWindow{public remaidWindow (int hour, int miniute){d=hour+":"+miniute;}public void remaidShow(){JOptionPane.showMessageDialog(null,"还点个毛线,知道你就要点了不去,点不点都得去,都  "+d+" 了,快去!!!", "Again :", JOptionPane.PLAIN_MESSAGE);JOptionPane.showMessageDialog(null,"咋地,还管不了你了,还点!", "Again :", JOptionPane.PLAIN_MESSAGE);JOptionPane.showMessageDialog(null,"点毛线了点,小样,你还能把我点完了!", "Again :", JOptionPane.PLAIN_MESSAGE);JOptionPane.showMessageDialog(null,"接着点啊,咋不点了,快洗澡去!!!", "Again :", JOptionPane.PLAIN_MESSAGE);}private String d;}class checkInput{public checkInput (String asetTime){Pattern pattern = Pattern.compile("[\\d{2}]:[\\d{2}]");Matcher matcher = pattern.matcher(asetTime);boolean checkNum=matcher.find();//System.out.println(checkNum);if (checkNum){String setTimeHour=asetTime.substring(0,2);String setTimeMinute=asetTime.substring(3,5);hour=Integer.parseInt(setTimeHour);minute=Integer.parseInt(setTimeMinute);//System.out.println(hour);//System.out.println(minute);}else{JOptionPane.showMessageDialog(null,"格式错了,要写成18:30这样的,重启动吧!", "格式警告!!!", JOptionPane.ERROR_MESSAGE);System.exit(0);}if (hour>24||minute>59){JOptionPane.showMessageDialog(null,"小逗比,这是你家自创的时间吧!"+"\n"+"重新启动吧", "警告:使用者智商太低!", JOptionPane.ERROR_MESSAGE);System.exit(0);}}public int returnHour(){return hour;}public int returnMinute(){return minute;}private int hour, minute;}

0 0