刚看到一则很搞笑的代码

cicada_IT 2007-08-30

代码如下:

java 代码
  1. import org.springframework.beans.BeanUtils;   
  2.   
  3. public class People {   
  4.     public class Contants {   
  5.         public static final int 情人节 = 120;   
  6.            
  7.         public static final int THING_ROSE = 1;   
  8.         public static final int THING_KISS = 2;   
  9.         public static final int THING_HUG = 3;   
  10.         public static final int THING_ANGRY = 4;   
  11.         public static final int THING_OTHER = 5;   
  12.            
  13.         public static final double MONEY = 100000.00;   
  14.         public static final int LOVE = 100;   
  15.         public static final int AGE = 30;   
  16.            
  17.     }   
  18.     public static  class Boy {   
  19.         private boolean 有车;   
  20.         private boolean 有房;   
  21.         private double 赚钱;   
  22.         private int 年龄 = 15;   
  23.            
  24.         public Boy() {   
  25.             super();   
  26.         }   
  27.         public Boy(boolean isOwnCar,boolean isOwnHouse) {   
  28.             有车 = isOwnCar;   
  29.             有房 = isOwnHouse;   
  30.         }   
  31.         public Boy(boolean isOwnCar,boolean isOwnHouse,double partMoeny) {   
  32.             有车 = isOwnCar;   
  33.             有房 = isOwnHouse;   
  34.             赚钱 = partMoeny;   
  35.         }   
  36.            
  37.         public void setBoy(Boy boy) {   
  38.             BeanUtils.copyProperties(this, boy);   
  39.         }   
  40.         public boolean  givegirl(int thing) {   
  41.             switch(thing) {   
  42.             case Contants.THING_ROSE:   
  43.             case Contants.THING_KISS:   
  44.             case Contants.THING_HUG:   
  45.                 return true;   
  46.             case Contants.THING_ANGRY:   
  47.             case Contants.THING_OTHER:   
  48.                 return false;   
  49.             }   
  50.             return false;   
  51.         }   
  52.         public void 拼命赚钱() {   
  53.             赚钱 ++;   
  54.         }   
  55.         public int get年龄() {   
  56.             return 年龄;   
  57.         }   
  58.         public void set年龄(int 年龄) {   
  59.             this.年龄 = 年龄;   
  60.         }   
  61.         public boolean is有车() {   
  62.             return 有车;   
  63.         }   
  64.         public void set有车(boolean 有车) {   
  65.             this.有车 = 有车;   
  66.         }   
  67.         public double get赚钱() {   
  68.             return 赚钱;   
  69.         }   
  70.         public void set赚钱(double 赚钱) {   
  71.             this.赚钱 = 赚钱;   
  72.         }   
  73.         public boolean is有房() {   
  74.             return 有房;   
  75.         }   
  76.         public void set有房(boolean 有房) {   
  77.             this.有房 = 有房;   
  78.         }   
  79.            
  80.     }   
  81.     public static  class Girl {   
  82.         private boolean 等;   
  83.         private int 感情;   
  84.         private int 生日;   
  85.            
  86.            
  87.         public Boy 嫁给(Boy boy) {   
  88.             return boy;   
  89.         }   
  90.         public boolean is等() {   
  91.             return 等;   
  92.         }   
  93.         public void set等(boolean 等) {   
  94.             this.等 = 等;   
  95.         }   
  96.         public int get感情() {   
  97.             return 感情;   
  98.         }   
  99.         public void set感情(int 感情) {   
  100.             this.感情 = 感情;   
  101.         }   
  102.         public int get生日() {   
  103.             return 生日;   
  104.         }   
  105.         public void set生日(int 生日) {   
  106.             this.生日 = 生日;   
  107.         }   
  108.     }   
  109.        
  110.     public  boolean loveLoad(Boy boy,Girl girl) {   
  111.         if (boy.is有房() && boy.is有车()) {   
  112.             boy.setBoy(null);   
  113.             girl.嫁给(boy);   
  114.         } else {   
  115.             if(girl.is等()) {   
  116.                 System.out.println("====1");   
  117.                 while (! (boy.get赚钱() > Contants.MONEY && girl.感情 > Contants.LOVE && boy.get年龄() < Contants.AGE)) {   
  118.                     System.out.println("====2");   
  119.                     for(int day = 1; day < 365 ; day ++) {   
  120.                         System.out.println("====3");   
  121.                         if(day == Contants.情人节) {   
  122.                             if(boy.givegirl(Contants.THING_ROSE)) {   
  123.                                 girl.set感情(girl.get感情() + 1);   
  124.                             } else {   
  125.                                 girl.set感情(girl.get感情() - 1);   
  126.                             }   
  127.                         }   
  128.                         if(day == girl.get生日()) {   
  129.                             if(boy.givegirl(Contants.THING_ROSE)) {   
  130.                                 girl.set感情(girl.get感情() + 1);   
  131.                             } else {   
  132.                                 girl.set感情(girl.get感情() - 1);   
  133.                             }   
  134.                         }   
  135.                         boy.拼命赚钱();   
  136.                     }   
  137.                     if(boy.is有房() && boy.is有车()) {   
  138.                         boy.setBoy(null);   
  139.                         girl.嫁给(boy);   
  140.                         return true;   
  141.                     }   
  142.                     boy.set年龄(boy.get年龄() + 1);   
  143.                     girl.set感情(girl.get感情() - 1);   
  144.                 }   
  145.                 if(boy.get年龄() > Contants.AGE) {   
  146.                     girl.嫁给(new Boy());   
  147.                     return false;   
  148.                 }   
  149.             } else {   
  150.                 girl.嫁给(new Boy());   
  151.                 return false;   
  152.             }   
  153.         }   
  154.         return false;   
  155.     }   
  156.     public  static void main(String []args) {   
  157.         People people = new People();   
  158.         Boy litterBoy = new Boy();   
  159.         litterBoy.set年龄(15);   
  160.         litterBoy.set有房(false);   
  161.         litterBoy.set有车(false);   
  162.         litterBoy.set赚钱(0.00);   
  163.         Girl goodGirl = new Girl();   
  164.         goodGirl.set生日(100);   
  165.         goodGirl.set感情(0);   
  166.         goodGirl.set等(true);   
  167.         System.out.println(people.loveLoad(litterBoy, goodGirl));   
  168.     }   
  169. }  
申明:这个是转来的,出自何方不清楚,反正来自互联网,作者是男是女,不祥。听说是女的。嘿嘿。。
xly_971223 2007-08-31
蛮经典滴
刑天战士 2007-08-31
煋,而且代码写的真烂!
tonywinslow1986 2007-09-03
very Lin-ish
andyaqu 2008-04-02
cicada_IT 写道

代码如下:

java 代码
  1. import org.springframework.beans.BeanUtils;   
  2.   
  3. public class People {   
  4.     public class Contants {   
  5.         public static final int 情人节 = 120;   
  6.            
  7.         public static final int THING_ROSE = 1;   
  8.         public static final int THING_KISS = 2;   
  9.         public static final int THING_HUG = 3;   
  10.         public static final int THING_ANGRY = 4;   
  11.         public static final int THING_OTHER = 5;   
  12.            
  13.         public static final double MONEY = 100000.00;   
  14.         public static final int LOVE = 100;   
  15.         public static final int AGE = 30;   
  16.            
  17.     }   
  18.     public static  class Boy {   
  19.         private boolean 有车;   
  20.         private boolean 有房;   
  21.         private double 赚钱;   
  22.         private int 年龄 = 15;   
  23.            
  24.         public Boy() {   
  25.             super();   
  26.         }   
  27.         public Boy(boolean isOwnCar,boolean isOwnHouse) {   
  28.             有车 = isOwnCar;   
  29.             有房 = isOwnHouse;   
  30.         }   
  31.         public Boy(boolean isOwnCar,boolean isOwnHouse,double partMoeny) {   
  32.             有车 = isOwnCar;   
  33.             有房 = isOwnHouse;   
  34.             赚钱 = partMoeny;   
  35.         }   
  36.            
  37.         public void setBoy(Boy boy) {   
  38.             BeanUtils.copyProperties(this, boy);   
  39.         }   
  40.         public boolean  givegirl(int thing) {   
  41.             switch(thing) {   
  42.             case Contants.THING_ROSE:   
  43.             case Contants.THING_KISS:   
  44.             case Contants.THING_HUG:   
  45.                 return true;   
  46.             case Contants.THING_ANGRY:   
  47.             case Contants.THING_OTHER:   
  48.                 return false;   
  49.             }   
  50.             return false;   
  51.         }   
  52.         public void 拼命赚钱() {   
  53.             赚钱 ++;   
  54.         }   
  55.         public int get年龄() {   
  56.             return 年龄;   
  57.         }   
  58.         public void set年龄(int 年龄) {   
  59.             this.年龄 = 年龄;   
  60.         }   
  61.         public boolean is有车() {   
  62.             return 有车;   
  63.         }   
  64.         public void set有车(boolean 有车) {   
  65.             this.有车 = 有车;   
  66.         }   
  67.         public double get赚钱() {   
  68.             return 赚钱;   
  69.         }   
  70.         public void set赚钱(double 赚钱) {   
  71.             this.赚钱 = 赚钱;   
  72.         }   
  73.         public boolean is有房() {   
  74.             return 有房;   
  75.         }   
  76.         public void set有房(boolean 有房) {   
  77.             this.有房 = 有房;   
  78.         }   
  79.            
  80.     }   
  81.     public static  class Girl {   
  82.         private boolean 等;   
  83.         private int 感情;   
  84.         private int 生日;   
  85.            
  86.            
  87.         public Boy 嫁给(Boy boy) {   
  88.             return boy;   
  89.         }   
  90.         public boolean is等() {   
  91.             return 等;   
  92.         }   
  93.         public void set等(boolean 等) {   
  94.             this.等 = 等;   
  95.         }   
  96.         public int get感情() {   
  97.             return 感情;   
  98.         }   
  99.         public void set感情(int 感情) {   
  100.             this.感情 = 感情;   
  101.         }   
  102.         public int get生日() {   
  103.             return 生日;   
  104.         }   
  105.         public void set生日(int 生日) {   
  106.             this.生日 = 生日;   
  107.         }   
  108.     }   
  109.        
  110.     public  boolean loveLoad(Boy boy,Girl girl) {   
  111.         if (boy.is有房() && boy.is有车()) {   
  112.             boy.setBoy(null);   
  113.             girl.嫁给(boy);   
  114.         } else {   
  115.             if(girl.is等()) {   
  116.                 System.out.println("====1");   
  117.                 while (! (boy.get赚钱() > Contants.MONEY && girl.感情 > Contants.LOVE && boy.get年龄() < Contants.AGE)) {   
  118.                     System.out.println("====2");   
  119.                     for(int day = 1; day < 365 ; day ++) {   
  120.                         System.out.println("====3");   
  121.                         if(day == Contants.情人节) {   
  122.                             if(boy.givegirl(Contants.THING_ROSE)) {   
  123.                                 girl.set感情(girl.get感情() + 1);   
  124.                             } else {   
  125.                                 girl.set感情(girl.get感情() - 1);   
  126.                             }   
  127.                         }   
  128.                         if(day == girl.get生日()) {   
  129.                             if(boy.givegirl(Contants.THING_ROSE)) {   
  130.                                 girl.set感情(girl.get感情() + 1);   
  131.                             } else {   
  132.                                 girl.set感情(girl.get感情() - 1);   
  133.                             }   
  134.                         }   
  135.                         boy.拼命赚钱();   
  136.                     }   
  137.                     if(boy.is有房() && boy.is有车()) {   
  138.                         boy.setBoy(null);   
  139.                         girl.嫁给(boy);   
  140.                         return true;   
  141.                     }   
  142.                     boy.set年龄(boy.get年龄() + 1);   
  143.                     girl.set感情(girl.get感情() - 1);   
  144.                 }   
  145.                 if(boy.get年龄() > Contants.AGE) {   
  146.                     girl.嫁给(new Boy());   
  147.                     return false;   
  148.                 }   
  149.             } else {   
  150.                 girl.嫁给(new Boy());   
  151.                 return false;   
  152.             }   
  153.         }   
  154.         return false;   
  155.     }   
  156.     public  static void main(String []args) {   
  157.         People people = new People();   
  158.         Boy litterBoy = new Boy();   
  159.         litterBoy.set年龄(15);   
  160.         litterBoy.set有房(false);   
  161.         litterBoy.set有车(false);   
  162.         litterBoy.set赚钱(0.00);   
  163.         Girl goodGirl = new Girl();   
  164.         goodGirl.set生日(100);   
  165.         goodGirl.set感情(0);   
  166.         goodGirl.set等(true);   
  167.         System.out.println(people.loveLoad(litterBoy, goodGirl));   
  168.     }   
  169. }  
申明:这个是转来的,出自何方不清楚,反正来自互联网,作者是男是女,不祥。听说是女的。嘿嘿。。

相关讨论