• 程序员写给老婆的代码(转)


    1. package kubi.coder.wife; 
    2.  
    3. /** 
    4.  * <p> 
    5.  * 这是一段Java程序写个他最爱的老婆的代码。<br> 
    6.  * 产生这个想法,是因为老婆要回老家几天,心里突然产生了无比依赖的感觉。<br> 
    7.  * 我现在只想对我的老婆说:<br> 
    8.  * <p> 
    9.  * <b>老婆,我爱你!</b> 
    10.  * </p> 
    11.  *  
    12.  * @author lihzh(苦逼coder) 
    13.  * @date 2012-5-25 下午9:23:11 
    14.  */ 
    15. public class 给最爱的老婆 { 
    16.  
    17.     // 老婆是私有,全局唯一,不可更改继承的 
    18.     private static final class 老婆 { 
    19.  
    20.         // 老婆,\r 代表换行 
    21.         private static final String 漂亮等级 = "世界上最美丽的\r"; 
    22.         private static final String 温柔等级 = "世界上最温柔的\r"; 
    23.         private static final String 勤劳等级 = "世界上最勤劳的\r"; 
    24.         private static final String 善良等级 = "世界上最善良的\r"; 
    25.         private static final String 可爱等级 = "世界上最可爱的\r"; 
    26.         private static final String 懂我等级 = "世界上最懂我的\r"; 
    27.         private static final String 疼我等级 = "世界上最疼我的\r"; 
    28.         private static final String 照顾我等级 = "世界上最精心照顾我的\r"; 
    29.         private static final String 对我的意义 = "你是我一生最爱的人\r"; 
    30.  
    31.         // 老婆是不能构造的,只能迎娶 
    32.         private 老婆() { 
    33.         } 
    34.  
    35.         private static final 老婆 marryMe() { 
    36.             return new 老婆(); 
    37.         } 
    38.  
    39.         private boolean 笑() { 
    40.             System.out.println("老婆笑了:)"); 
    41.             return true; 
    42.         } 
    43.  
    44.         private boolean 哭() { 
    45.             System.out.println("呜呜,老婆伤心了。"); 
    46.             return true; 
    47.         } 
    48.  
    49.         private boolean 不在家() { 
    50.             System.out.println("老婆不在家。"); 
    51.             return true; 
    52.         } 
    53.  
    54.         private void 生气了() { 
    55.             throw new 老婆很生气Exception("老婆今天很生气,不爱理你。"); 
    56.         } 
    57.  
    58.         private void 破涕为笑() { 
    59.             System.out.println("老婆破涕为笑。"); 
    60.         } 
    61.  
    62.         @Override 
    63.         public String toString() { 
    64.             return "老婆你是:\r" + 漂亮等级 + 温柔等级 + 勤劳等级 + 善良等级 + 可爱等级 
    65.                     + "你也是:\r" + 懂我等级 + 疼我等级 + 照顾我等级 + "总之,\r" + 对我的意义; 
    66.         } 
    67.  
    68.     } 
    69.  
    70.     /* 
    71.      * 老婆很生气异常 
    72.      */ 
    73.     private static final class 老婆很生气Exception extends RuntimeException { 
    74.  
    75.         private static final long serialVersionUID = 7260098074598571319L; 
    76.  
    77.         private 老婆很生气Exception(String msg) { 
    78.             super(msg); 
    79.         } 
    80.     } 
    81.  
    82.     public static void main(String[] args) { 
    83.         老婆 myWife = 老婆.marryMe(); 
    84.         System.out.println("老婆,首先我想对你说:" + myWife); 
    85.  
    86.         System.out.println("如果你笑,"); 
    87.         if (myWife.笑()) { 
    88.             System.out.println("我更加高兴。\r"); 
    89.         } 
    90.  
    91.         System.out.println("如果你哭,"); 
    92.         if (myWife.哭()) { 
    93.             System.out.println("我哄你笑。\r"); 
    94.         } 
    95.  
    96.         if (myWife.不在家()) { 
    97.             System.out.println("我就很难入睡。\r"); 
    98.         } 
    99.  
    100.         System.out.println("生活中难免有琐碎、摩擦。"); 
    101.         try { 
    102.             myWife.生气了(); 
    103.         } catch (老婆很生气Exception e) { 
    104.             System.out.println(e.getMessage()); 
    105.             System.out.println("都是我的错,是我不好。请老婆不要生气。"); 
    106.         } finally { 
    107.             System.out.println("直到...."); 
    108.             myWife.破涕为笑(); 
    109.             // 为了空行 
    110.             System.out.println(); 
    111.         } 
    112.  
    113.         int myAge = 28; 
    114.         // 爱你一万年 
    115.         while (myAge <= 10028) { 
    116.             boolean 我是否爱你 = true; 
    117.             myAge++; 
    118.         } 
    119.          
    120.         System.out.println("希望能就这样平平静静的牵你手,一直走。"); 
    121.         System.out.println("我爱你,我的老婆。"); 
    122.         System.out.println("\t ——你的老公(苦逼coder)于:2012年5月25日晚"); 
    123.     } 
    124.  

    运行后结果:

    老婆,首先我想对你说:老婆你是:

    世界上最美丽的

    世界上最温柔的

    世界上最勤劳的

    世界上最善良的

    世界上最可爱的

    你也是:

    世界上最懂我的

    世界上最疼我的

    世界上最精心照顾我的

    总之,

    你是我一生最爱的人

     

    如果你笑,

    老婆笑了:)

    我更加高兴。

     

    如果你哭,

    呜呜,老婆伤心了。

    我哄你笑。

     

    老婆不在家。

    我就很难入睡。

     

    生活中难免有琐碎、摩擦。

    老婆今天很生气,不爱理你。

    都是我的错,是我不好。请老婆不要生气。

    直到....

    老婆破涕为笑。

     

    希望能就这样平平静静的牵你手,一直走。

    我爱你,我的老婆。

         ——你的老公(苦逼coder)于:2012年5月25日晚

  • 相关阅读:
    javascript闭包的理解
    关于打印
    CozyShark开发日志 3章节
    CozyShark开发日志 2章节
    CozyShark开发日志 1.5章节
    CozyShark开发日志 1章节
    CozyShark开发日志 0章节
    WPF:设置DataGrid中DataGridColumn列的普通样式和编辑样式
    Windows Phone开发学习笔记(1)---------自定义弹框
    一个简单的ASP.NEW MVC4网站(二)
  • 原文地址:https://www.cnblogs.com/belingzhong/p/2519386.html
Copyright © 2020-2023  润新知