CSDNU1234 2022-10-06 21:24 采纳率: 0%
浏览 34
已结题

talk小程序的驱动

这是一个talk的程序的驱动程序

package main.java;

import java.io.IOException;

/** Driver class for the Talk socket application. */
public class Talk {

  /**
   * The program behaves as a client with the specified client connection.
   * @param client the client interface to use for socket communication
   * @return {@code false} if the host is not available
   * @throws never should return {@code false} rather than throwing an exception
   */
  protected boolean clientMode(BasicTalkInterface client) {
    
    //任务return FALSE 如果host 不可用

    return false;
  }

  /**
   * The program behaves as a server with the specified server.
   * @param server the server interface to use for socket communication
   * @return {@code false} if the port is not available
   * @throws never should return {@code false} rather than throwing an exception
   */
  protected boolean serverMode(BasicTalkInterface server) {

    //任务return FALSE 如果host 不可用

    return false;
  }

  /**
   * The program enters auto mode and behaves as a client attempting to connect to the specified
   * host on the specified port. If the host is not available, the program should behave as a
   * server listening for connections on the specified port.
   * @param hostname the host to connect to
   * @param portnumber the port to connect to or listen on
   * @return {@code false} if the host and port are both unavailable
   * @throws never should return {@code false} rather than throwing an exception
   */
  public boolean autoMode(String hostname, int portnumber) {

    //任务call clientMode and serverMode
    
    return false;
  }

  /**
   * The program behaves as a client connecting to the specified host on the specified port.
   * @param hostname the host to connect to
   * @param portnumber the port to connect to
   * @return {@code false} if the host is not available
   * @throws never should return {@code false} rather than throwing an exception
   */
  public boolean clientMode(String hostname, int portnumber) {
    try {
      return this.clientMode(new TalkClient(hostname, portnumber));
    } catch (IOException e) {
      return false;
    }
  }

  /**
   * Should print your name and instructions on how to use the talk program. Instructions must
   * at least include the line "Talk [-a | –h | -s] [hostname | IPaddress] [–p portnumber]"
   */
  public void helpMode() {

    // 
  }

  /**
   * The program behaves as a server listening for connections on the specified port.
   * @param portnumber the port to listen for connections on
   * @return {@code false} if the port is unavailable
   * @throws never should return {@code false} rather than throwing an exception
   */
  public boolean serverMode(int portnumber) {
    try {
      return this.serverMode(new TalkServer(portnumber));
    } catch (IOException e) {
      return false;
    }
  }

  /**
   * Parses the specified args and executes the talk program in its intended mode.
   * @param args the CLI args
   * @throws never should return {@code false} rather than throwing an exception
   */
  public boolean start(String[] args) {
    
    // 任务调出autoMode, clientMode, helpMode, and serverMode
    return false;
  }

  public static void main(String[] args) {
    System.exit(new Talk().start(args) ? 0 : 1);
  }
}


  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 10月14日
      • 创建了问题 10月6日

      悬赏问题

      • ¥15 Java建模,处理文件和对象
      • ¥15 linux磁盘怎样重新挂载到原挂载路径下
      • ¥15 Java的类和静态方法
      • ¥15 存在一定规律的数据转置和整理
      • ¥15 关于flowable工作流开发的一个问题
      • ¥20 VBA如何用代码在onedrive创建文件夹?
      • ¥15 多理发师睡眠问题,2个理发师,n个座椅
      • ¥15 FPGA两按键控制led灯程序
      • ¥40 大学的python问题,用python解决
      • ¥30 用Java实现网上商场购物车功能