zoukankan      html  css  js  c++  java
  • SSD 3 Practical Quiz 1 答案

    import java.io.*;
    import java.util.*;

    /**
     * @version 1.0.0
     * @author vivizhyy
     */
    public class ICarnegieInfoApplication {

        private static BufferedReader stdIn = new BufferedReader(
                new InputStreamReader(System.in));
        private static PrintWriter stdOut = new PrintWriter(System.out, true);
        private static PrintWriter stdErr = new PrintWriter(System.err, true);
        private int choice;

        /* DOCUMENT THIS PUBLIC METHOD */
        public static void main(String[] args) throws IOException {

            ICarnegieInfo companyInfo = ICarnegieInfo.getInstance();

            int choice = getChoice();

            while (choice != 0) {

                if (choice == 1) {
                    stdOut.println(companyInfo.getName());
                } else if (choice == 2) {
                    stdOut.println(companyInfo.getAddress());
                } else if (choice == 3) {
                    stdOut.println(companyInfo.getTelephone());
                } else if (choice == 4) {
                    stdOut.println(companyInfo.getEmail());
                } else if (choice == 5) {
                    stdOut.println(companyInfo.getUrl());
                }

                choice = getChoice();
            }
        }

        private static int getChoice() throws IOException {
            int input = 0;
            /* PLACE YOUR CODE HERE */

            try {
                stdErr
                        .print("[0] Quit/n[1] Display name/n[2] Display address"
                                + "/n[3] Display telephone/n[4] Display email/n[5] Display URL"
                                + "/nchoice>");
                stdErr.flush();
                input = Integer.parseInt(stdIn.readLine());
                if (input < 0 || input > 5) {
                    System.out.println("Invalid choice: " + input);
                }
            } catch (NumberFormatException nfe) {
                 nfe.printStackTrace();//写一大段
                // System.out.println(nfe.getMessage()); the output result
                // was just "For input string "aa""
                // System.out.println(nfe.getCause()); output "null"
                // System.out.println(nfe.getLocalizedMessage()); the same as
                // .getMessage
                //stdErr.println(nfe.getMessage());// the same as .getMessage
                input=getChoice();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            return input; /* CHANGE THIS STATEMENT AS NEEDED */
        }

    }
  • 相关阅读:
    第02组 Beta冲刺(1/4)
    第02组 Alpha事后诸葛亮
    第02组 Alpha冲刺(4/4)
    第02组 Alpha冲刺(3/4)
    团队作业6——复审与事后分析(集合贴)
    事后诸葛亮分析报告
    Alpha阶段项目复审
    团队作业5——测试与发布(Alpha版本)
    团队作业四——七天的敏捷冲刺日志集合贴
    第 7 篇 Scrum 冲刺博客
  • 原文地址:https://www.cnblogs.com/vivizhyy/p/3394924.html
Copyright © 2011-2022 走看看