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

📄 telephone.java

📁 这个是学习网络编程的好好文档! 里面有一些老师发给的学习jsp的课件!
💻 JAVA
字号:
import java.io.BufferedReader;
import java.io.IOException;

/**
   A telephone that takes simulated keystrokes and voice input
   from the user and simulates spoken text.
*/
public class Telephone
{
   /**
      Construct phone object.
      @param aReader that reads text from a character-input stream
   */
   public Telephone(BufferedReader aReader)
   {
      reader = aReader;
   }

   /**
      Speak a message to System.out.
      @param output the text that will be "spoken"
   */
   public void speak(String output)
   {
      System.out.println(output);
   }

   /**
      Loops reading user input and passes the input to the 
      Connection object's methods dial, record or hangup.
      @param c the connection that connects this phone to the 
      voice mail system
   */
   public void run(Connection c) throws IOException
   {
      boolean more = true;
      while (more)
      {
         String input = reader.readLine();
         if (input == null) return;
         if (input.equalsIgnoreCase("H"))
            c.hangup();
         else if (input.equalsIgnoreCase("Q"))
            more = false;
         else if (input.length() == 1 
            && "1234567890#".indexOf(input) >= 0)
            c.dial(input);
         else            
            c.record(input);
      }
   }

   private BufferedReader reader;
}

⌨️ 快捷键说明

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