佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

搜索
查看: 2291|回复: 26

bz请删贴 java 问题

  [复制链接]
发表于 31-10-2010 09:34 PM | 显示全部楼层 |阅读模式
本帖最后由 acezai 于 12-12-2010 05:31 PM 编辑

如果像酱的java,要怎样打出来?

Write a Java program for a furniture company. Ask the user to choose Pfor Pine, O for Oak or M for Mahogany. Show the price of a table manufacturedwith the chosen wood. Pine tables cost $100, oak tables cost $225 and mahoganytables cost $310.


小弟刚学,不太会!!请大大帮忙!!
回复

使用道具 举报


ADVERTISEMENT

发表于 31-10-2010 09:42 PM | 显示全部楼层
Write a Java program for a furniture company. Ask the user to choose P for Pine, O for Oak or M for Mahogany. Show the price of a table manufacturedwith the chosen wood. Pine tables cost $100, oak tables cost $225 and mahoganytables cost $310.

资料咯
input
output

就酱咯,而且只可以输入P,O,M,然后显示相应的output咯。
回复

使用道具 举报

发表于 31-10-2010 10:34 PM | 显示全部楼层
给你 KEY WORD 。 你自己 GOOGLE 找找吧

Scanner  
Case ...Break ... Default
回复

使用道具 举报

发表于 6-11-2010 06:57 PM | 显示全部楼层
回复 1# acezai

用char + switch 就能做到
回复

使用道具 举报

发表于 8-11-2010 11:32 AM | 显示全部楼层
给你 KEY WORD 。 你自己 GOOGLE 找找吧

Scanner  
Case ...Break ... Default
兔仙人 发表于 31-10-2010 10:34 PM



   HashTable 不能吗?
回复

使用道具 举报

发表于 8-11-2010 11:46 AM | 显示全部楼层
可以
回复

使用道具 举报

Follow Us
发表于 8-11-2010 02:00 PM | 显示全部楼层
回复 6# 兔仙人

OK, 这问题没啥好讨论的,大家答案一致,楼主问题解决, 帖可以关鸟。
回复

使用道具 举报

 楼主| 发表于 15-11-2010 06:55 PM | 显示全部楼层
小弟有另外一个问题...

A small ferry company has just purchased a computer for its new automated ticketing system. The company director has asked you to design the new system to assign seats for each trip of the 50-seater ferry, which covers the route from Penang Island to Langkawi Island and back daily. The upper deck of the ferry is reserved for business class passengers and can accommodate 10 people. The main deck of the ferry, the economy class can accommodate 40 people. Assume the company has at least 8 ferries - each with a different Ferry ID, which travel at one-hour intervals from 10 am to 5 pm daily.


Alternative seating
When the business class is full, your program should ask the person if it is acceptable to be placed in the economy class (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message “Next trip leaves in 1 hour”.

在internet看到的..可是小弟不知要如何solve...
回复

使用道具 举报


ADVERTISEMENT

发表于 15-11-2010 11:28 PM | 显示全部楼层
本帖最后由 兔仙人 于 18-11-2010 05:28 PM 编辑

  1. package TicketSystem;

  2. import java.util.Date;

  3. public class OperTicketSystemAction implements ITicketSystem {

  4.     static final String BUSINESS_CLASS_TYPE = "1";
  5.     static final String ECONOMY_CLASS_TYPE = "2";

  6.     static final Integer START_WORKING = 10;
  7.     static final Integer END_WORKING = 17;

  8.     static final Integer UPPER_DECK = 10;
  9.     static final Integer MAIN_DECK = 40;

  10.     Boolean isBusinessFull = false;
  11.     Boolean isEconomyFull = false;
  12.    
  13.     // Continue this Part - checking working time.

  14.     public void doSellTicket(String ClassType, Date timeTrip) {
  15.         if (ClassType.equals(BUSINESS_CLASS_TYPE)) {
  16.             Boolean isAvailable = checkAvailableSeat(ClassType, timeTrip);
  17.             if (isAvailable) {
  18.                 // do Something
  19.             }

  20.             else {
  21.                 return;
  22.             }
  23.         }

  24.         if (ClassType.equals(ECONOMY_CLASS_TYPE)) {
  25.             Boolean isAvailable = checkAvailableSeat(ClassType, timeTrip);
  26.             if (isAvailable) {
  27.                 // do Something
  28.             }

  29.             else {
  30.                 return;
  31.             }
  32.         }
  33.     }

  34.     public Boolean checkAvailableSeat(String ClassType, Date timeTrip) {

  35.         Integer passagerCount;

  36.         if (ClassType.equals(BUSINESS_CLASS_TYPE)) {

  37.             passagerCount = getPassagerCount(ClassType, timeTrip);
  38.             if ((UPPER_DECK - passagerCount) > 0) {
  39.                 isBusinessFull = Boolean.FALSE;
  40.                 return !isBusinessFull;
  41.             }
  42.         }

  43.         if (ClassType.equals(ECONOMY_CLASS_TYPE)) {

  44.             passagerCount = getPassagerCount(ClassType, timeTrip);
  45.             if ((MAIN_DECK - passagerCount) > 0) {
  46.                 isEconomyFull = Boolean.FALSE;
  47.                 return !isEconomyFull;
  48.             }
  49.         }

  50.         return Boolean.FALSE;
  51.     }

  52.     @Override
  53.     public Integer getPassagerCount(String classType, Date createdTimeStamp) {
  54.         // do Something  
  55.         Integer a ;
  56.         return a;
  57.     }

  58. }
复制代码


做着 那么多先  , 明天继续
回复

使用道具 举报

 楼主| 发表于 15-11-2010 11:38 PM | 显示全部楼层
谢谢..等你!!
回复

使用道具 举报

 楼主| 发表于 16-11-2010 06:36 PM | 显示全部楼层
有些不明白。。可以解释下吗?
回复

使用道具 举报

 楼主| 发表于 17-11-2010 12:35 AM | 显示全部楼层
public class OperTicketSystemAction implements ITicketSystem {

这句,怎样讲?
回复

使用道具 举报

发表于 18-11-2010 02:30 PM | 显示全部楼层
public class OperTicketSystemAction implements ITicketSystem {

这句,怎样讲?
acezai 发表于 17-11-2010 12:35 AM


不好意思 , 用了 INTERFACE , 其实不需要的 。
回复

使用道具 举报

 楼主| 发表于 18-11-2010 05:21 PM | 显示全部楼层
回复 13# 兔仙人


    #  // do Something  , a = constant value ;
#         Integer a = null;
#         Integer passagerCount = a;
#         return passagerCount;

这个呢?不是很明
回复

使用道具 举报

发表于 18-11-2010 05:26 PM | 显示全部楼层
回复  兔仙人


    #  // do Something  , a = constant value ;
#         Integer a = null;
#    ...
acezai 发表于 18-11-2010 05:21 PM


getPassagerCount -  从DB那边找出人数 , 看看 1 个 TRIP 的人数 满了没有 。

其实也是可以 IGNORE 的
回复

使用道具 举报

 楼主| 发表于 18-11-2010 05:31 PM | 显示全部楼层
final String 和 final integer 有设么分别?
回复

使用道具 举报


ADVERTISEMENT

发表于 18-11-2010 08:46 PM | 显示全部楼层
final String 和 final integer 有设么分别?
acezai 发表于 18-11-2010 05:31 PM


final 的意思 , 就是 把 一个 variable SET 死死 。

有如 CONSTANTS 的意思  
回复

使用道具 举报

 楼主| 发表于 18-11-2010 08:53 PM | 显示全部楼层
明白了...酱如果Boolean的话,又是怎样用呢?

# Boolean isBusinessFull = false;
#     Boolean isEconomyFull = false;



Boolean isAvailable = checkAvailableSeat(ClassType, timeTrip);
回复

使用道具 举报

发表于 19-11-2010 12:01 AM | 显示全部楼层
Method 那边 已经写清楚了

我要 CHECK CHECK 还有没有 空余的 位子
回复

使用道具 举报

 楼主| 发表于 19-11-2010 12:14 AM | 显示全部楼层
我的意识是怎样用boolean,设么时候用?因为老师没有教
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2026 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 24-5-2026 01:55 PM , Processed in 0.084751 second(s), 11 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表