SSD3答案 完整版

上传者: coolqzg | 上传时间: 2022-04-24 21:43:28 | 文件大小: 1.9MB | 文件类型: RAR
卡耐基梅陇的SSD课程答案 import java.io.*; import java.util.*; /* DOCUMENT THIS CLASS */ public class ShoppingCartApplication { 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 ShoppingCart cart; /* DOCUMENT THIS PUBLIC METHOD */ public static void main(String[] args) throws IOException { ShoppingCartApplication application = new ShoppingCartApplication(); application.run(); } private void run() throws IOException { cart = new ShoppingCart(); int choice = getChoice(); while (choice != 0) { if (choice == 1) { cart.addProduct(readProduct()); } else if (choice == 2) { stdOut.println(cart.toString()); } else if (choice == 3) { stdOut.println(cart.getTotalValue()); } choice = getChoice(); } } private int getChoice() throws IOException { do { int input; try { stdErr.println(); stdErr.print("[0] Quit\n" + "[1] Add Product\n" + "[2] Display Products\n" + "[3] Display Total\n" + "choice>"); stdErr.flush(); input = Integer.parseInt(stdIn.readLine()); if (0 <= input && 3 >= input) { return input; } else { stdErr.println("Invalid choice: " + input); } } catch (NumberFormatException nfe) { stdErr.println(nfe); } } while (true); } private Product readProduct() throws IOException { final String DELIM = "_"; String name = ""; int quantity = 0; double price = 0.0; /* PLACE YOUR CODE HERE */ for (;;) { try { stdErr.print("product [name_qty_price]> "); stdErr.flush(); String s = stdIn.readLine(); StringTokenizer st = new StringTokenizer(s, DELIM); if (st.countTokens() != 3) { stdErr.println("Invalid input"); } else { name = st.nextToken(); quantity = Integer.parseInt(st.nextToken()); price = Double.parseDouble(st.nextToken()); if ((quantity >= 0) && (price >= 0.0D)) { return new Product(name, quantity, price); } stdErr.println("Invalid input"); } } catch (NumberFormatException iae) { stdErr.println(iae); } } } }

文件下载

资源详情

[{"title":"( 102 个子文件 1.9MB ) SSD3答案 完整版","children":[{"title":"Multiple-Choice.chm <span style='color:#111;'> 39.85KB </span>","children":null,"spread":false},{"title":"student-files.zip <span style='color:#111;'> 7.89KB </span>","children":null,"spread":false},{"title":"Practical Quiz 7.pdf <span style='color:#111;'> 89.03KB </span>","children":null,"spread":false},{"title":"StudentArrayList.java <span style='color:#111;'> 5.57KB </span>","children":null,"spread":false},{"title":"TestStudentArrayList.java <span style='color:#111;'> 9.56KB </span>","children":null,"spread":false},{"title":"......","children":null,"spread":false},{"title":"<span style='color:steelblue;'>文件过多,未全部展示</span>","children":null,"spread":false}],"spread":true}]

评论信息

  • cbx052 :
    旧版的……只有部分可用……但总比没有可用的强
    2013-05-04
  • wulinzhi1001 :
    只有部分一致!
    2012-11-15
  • fcntln :
    exercise的答案还是可以用的,和新版略有不同,选择题答案是和题号是对不上的
    2012-03-22
  • yayatongnian :
    exercise只有1到5。。失望了,但还是谢谢了
    2011-12-07
  • jay0lu :
    用的新版的 还是谢了
    2011-12-06

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明