程序情话--一个程序员的另类诉说

今天闲来无事,又开始胡思乱想了,即兴发挥写了这样一小段程序,仅供消遣,呵呵。请不要自我套用,

以免引起误会。

package com.baiyyy.yt.others;

/**
 * 爱情程序,一段程序描写了一段心情
 * 一个程序员的另类述说
 @author yongtree
 
 */
public class Love {

  // 我们之间的结局
  public boolean loveResult(Me me, You you) {
    me.Miss(you.getName(), me.getWaitTime());
    if (me.whoILove().equals(you.getName())) {
      if (you.whoYouLove().equals(me.getName())) {
        return true;
      else {
        return false;
      }
    else {
      return false;
    }
  }

  /**
   @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    Love love = new Love();
    Me me = new Me();
    me.setName("yt");
    me.setWaitTime(2);
    You you = new You();
    you.setName("bh");
    /**
     * 当开始写这段程序时,就已经知道我们之间不是完美的结局,不管多少个if、假设,解决已经注定我们不会在一起,
     * 打印的语句永远是"缘分不到",除非你改变了注意,修改了属于你的程序
     */
    if (love.loveResult(me, you)) {
      System.out.println("我很幸福");
    else {
      System.out.println("缘分不到");
    }
  }

}

/**
 * 描述我的类
 @author yongtree
 *
 */
class Me extends Person {

  int waitTime;

  You you = new You();

  //这个是返回我爱谁的方法,其实在我的心里我就已经把这个人设定成了你
  public String whoILove() {
    you.setName("bh");
    String name = you.getName();
    System.out.println("我说:"+name + ",I love you!");
    return name;
  }

  public void Miss(String name, int years) {
    System.out.println("思念是一种幸福!");
    if (years < 2) {
      years = 2;//两年的有期徒刑,呵呵
    }
    for (int i = 0; i < years; i++) {
      System.out.println(name + ",我每天都想你无法入睡。");
      System.out.println("时时刻刻的思念是一种折磨");
      // break;好像加上这个break语句,让我从这种痛苦中解脱出来,但是还是忍不住把它注释掉了,依然选择了重复这种折磨
    }
  }

  public int getWaitTime() {
    return waitTime;
  }

  public void setWaitTime(int waitTime) {
    this.waitTime = waitTime;
  }
}
/**
 * 描述你的类
 @author yongtree
 *
 */
class You extends Person {
  public String whoYouLove() {
    Other other = new Other();
    other.setName("x");// 不知道是谁的名字,只有你清楚。
              //很多时候我都想把Other这个对象强制转换成Me,但我知道这样是徒劳的。
    String name = other.getName();
    System.out.println("你说:"+name + ",I love you!");
    return name;
  }

}

/**
 * 描述其他人的类
 @author yongtree
 *
 */
class Other extends Person {

}

/**
 * 描述人的类
 @author yongtree
 *
 */
class Person {
  String name;

  int age;

  String sex;

  /* .......... */

  /**
   * 人的其他属性(略)
   */
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getSex() {
    return sex;
  }

  public void setSex(String sex) {
    this.sex = sex;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

}

输出结果:

思念是一种幸福!
bh,我每天都想你无法入睡。
时时刻刻的思念是一种折磨
bh,我每天都想你无法入睡。
时时刻刻的思念是一种折磨
我说:bh,I love you!
你说:x,I love you!
缘分不到

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值