⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gotapplicationstate.java

📁 程序设计模式java入门源码大全
💻 JAVA
字号:
import java.util.*;
import java.lang.Math;

public class GotApplicationState implements State
{
  AutomatInterface automat;
  Random random; 

  public GotApplicationState(AutomatInterface d)
  {
    automat = d;
    random = new Random(System.currentTimeMillis());
  }

  public String gotApplication()
  {
    return "We already got your application.";
  }

  public String checkApplication()
  {
    int yesno = random.nextInt() % 10;

    if (yesno > 4 && automat.getCount() > 0) {
      automat.setState(automat.getApartmentRentedState());
      return "Congratulations, you were approved.";
    } else {
      automat.setState(automat.getWaitingState());
      return "Sorry, you were not approved.";
    }
  }

  public String rentApartment()
  {
    return "You must have your application checked.";
  }

  public String dispenseKeys()
  {
    return "You must have your application checked.";
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -