Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 1616|回复: 10
打印 上一主题 下一主题

java编程 请大家帮忙看看

[复制链接]

8

主题

0

好友

36

积分

初级会员

Rank: 1

跳转到指定楼层
1#
发表于 2010-3-4 12:08 AM |只看该作者 |倒序浏览
请大家帮我看看怎么编,如何下手。

十分感谢,如果大家可以帮忙。


   
public class Department
{
   
    /**Returns the location of the department as a String
     * @return the location of the department as a String
     **/
    public String getSite();
   
   
    /**Returns a String representation of the department,including
     * its location and all its copiers
     * @return a String representation of the department,including
     * its location and all its copiers
     **/
    public String toString();
   
   
    /**Returns a String representation of the customers who have used the
     * department's services
     * @return a String representation of the customers who have used the
     * department's services
     **/
    public String getAllCustomers();
        
// ***************** Copiers ************************   
    /** Allows a laser copier to be added to the department.The maximum
     * number of copies which can be done in one request for a laser
     * copier is 20.The copier's availability is set to "available"
     * @param reg represents the depratmental code of the copier
     **/   
     
     public void addCopier(String id);
     
   
    /** Allows a colour copier to be added to the department.The maximum
     * number of copies which can be done in one request for a colour
     * copier is 10.The copier's availability is set to "available"
     * @param reg represents the departmental code of the copier
     * @param photo is true if the copier can produce "photo quality" prints   
     **/   
     
     public void addCopier(String id, boolean photo);
     
   
    /** Allows a plain paper copier to be added to the department. The
     * maximum number of copies allowed in one request is set from the
     * parameter value.The copier's availability is set to "available"
     * @param id represents the departmental identifier of the copier
     * @param max gives the maximum number of copies allowed in one request
     * @param make gives the copier's manufacturer
     **/
    public void addCopier(String id,int max, String make);
   
    /** Sets the contact details for the repair technician of a copier, but is
     * only used for plain paper copiers
     * @param id represents the departmental identifier of the copier
     * @param details gives the contact details for the repair technician
     */
    public void setContactDetails(String id, String details);
   
   
    /** Returns a String representation of all the copiers  
     * @return returns a String representation of all copiers
     **/
    public String getAllCopiers();
   
   
    /** Returns true if the copier with the departmental identifier
     * can be found in the system, false otherwise.
     * @param depId represents the departmental identifier of the copier
     * @return returns true if the copier with the departmental identifier
     * can be found, false otherwise.
     **/
    public boolean isCopier(String depId);
   
   
    /** Removes a copier from the department. pre-condition: isCopier(depId)
     * @param depId represents the departmental identifier of the copier
     **/
    public void removeCopier(String depId);
   
//**************************************************************
    /** Adds a request to the request list if it is possible.Requests for more than
     * 20 copies which require either high quality or colour are not
     * possible.If not possible "Request not possible" is returned.Requests
     * which are possible are number sequentially from 100 and the
     * customer added to a set of customers.If a suitable copier is
     * available,the state of the request is set to "printing",the selected
     * copier is added to the request and the copier's state is set to "in
     * use".If a copier is not available, request's state is set to "waiting".If
     * a suitable copier cannot be found,"Request waiting" is returned,
     * other wise "Request ready for printing on:" with the copier details.
     * @cust is the name of the customer
     * @staff indicates whether the customer is a member of staff
     * @number is either department number if staff, or student number,if student
     * @pages is the number of pages in the documents
     * @copies is the number of copies required
     * @param col indicates whether colour is required
     * @param hQuality indicates whether high quality is required
     * @param dsided indicates whether double-sided is required
     * @return returns "Request not possible"if the request is not possible,
     * "Request waiting" if no copier is available, else "Request ready for
     * printing on:" together with the copier details
     **/
     public String addRequest(String cust,boolean staff,int number,int pages,
           int copies, boolean hQuality, boolean col, boolean dsided);

           
    /** Provides a String representation of all requests
     * @return returns a String representation of of all requests
     **/
    public String getAllRequests();
   
   
    /** Provides a String representation of all requests which are
     * still waiting for printing
     * @return returns a String representation of all requests which are
     * still waiting for printing
     **/
    public String getRequestsWaiting();
   
    /** records that the request specified by the parameter value has been
     * done.If the request cannot be found return -1.If the request can be
     * found,the state of the request is set to "done" ,the state of its
     * copier is set to "available" and 0 is returned.
     **/
    public int setRequestDone(int jNo);
   
   
    /** Returns the cost of request specified by the parameter value once a
     * has been printed.If the request cannot be found or the printing has
     * not been done return -1.Copies printed on colour copiers are charged
     * at 15p per copy per page.A laser printed copy costs 6p per copy per
     * page (whether double-sided or not)and plain paper copy 4p per copy per
     * page,unless the printing is double-sided in which case the cost is  
     * 3p per copy per page.There is a set up cost of � per request with an
     * additional single cost of � for colour.
     *
     * @param requestNo is the number of the request
     * @return the cost of a request calculated as described above
     **/
    public double getRequestCost(int jNo);
   
     
    /** Checks the list of requests and returns the request number of the first
     * request for which a printer is now available.If such a request is found,
     * the state of the request is set to "printing", the selected copier is
     * added to the request information and the copier's state is set to
     * "in use"and the request number is returned.If there no such requests,
     * return -1
     **/
    public int checkforRequestsWaiting();
   

// ***************   file write/read  *********************
// Methods required for Task 5 ONLY - not required for the demo
// If you do not implement these, just comment them out

    /** Writes all requests to the specified file
     * @param fname name of file storing requests
     */
    public void writeRequestsToFile(String fname);
   
    /** reads all requests from the specified file and stores
     * @param fname name of file storing requests
     */
    public void readRequestsFromFile(String fname);

   
    /** reads data about copiers from a text file and stores in collection of
     * copiers.Data in the file is  "comma separated" and so editable
     * @param fileName name of the file to be read
     */
    public void initialiseCopiersFromFile(String fileName);

   
    /** writes data about copiers to a text file from collection of
     * copiers.Data in the file is to be "comma separated" and so editable
     * @param fileName name of the file to which copiers are written
     */
    public void saveCopiersToFile(String fileName);


}




收藏收藏0

8

主题

0

好友

36

积分

初级会员

Rank: 1

2#
发表于 2010-3-4 12:09 AM |只看该作者

复印机的位子在Hendon



回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

3#
发表于 2010-3-4 01:23 AM |只看该作者
原帖由 Xis 于 2010-3-4 12:08 AM 发表
请大家帮我看看怎么编,如何下手。

十分感谢,如果大家可以帮忙。


   
public class Department
{
   
    /**Returns the location of the department as a String
     * @return the location ...



貼出了 interface 然後呢?? 是要我們幫你寫 method 嗎??


回复

使用道具 举报

8

主题

0

好友

36

积分

初级会员

Rank: 1

4#
发表于 2010-3-4 05:28 AM |只看该作者

回复 #3 Super-Tomato 的帖子

是的, 如果能的话最好了。

这是作业 的一部分(最基本的 ) 我刚刚学java所以不是很明白怎么去写。

十分感谢。


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

5#
发表于 2010-3-4 01:36 PM |只看该作者
原帖由 Xis 于 2010-3-4 05:28 AM 发表
是的, 如果能的话最好了。

这是作业 的一部分(最基本的 ) 我刚刚学java所以不是很明白怎么去写。

十分感谢。



那麼我只能說 "天下沒有白吃的午餐", 所以目前就只有兩條路
1. 儘早轉科系
2. 動手做, 不明白的才翻書或提問而不是要求別人代勞


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

6#
发表于 2010-3-4 03:34 PM |只看该作者

回复 #4 Xis 的帖子

已经给你了 需要什么 param ,return 什么东西回去了。

不需要人家教了吧~ 你现在最主要就是懂 method 里面怎么code 罢了。

一定是上课没听课的了。

加油


回复

使用道具 举报

10

主题

0

好友

862

积分

青铜长老

Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

7#
发表于 2010-3-4 04:53 PM |只看该作者
原帖由 Super-Tomato 于 2010-3-4 01:23 AM 发表



貼出了 interface 然後呢?? 是要我們幫你寫 method 嗎??

他这个好像连interface都不是
看起来就是。。。class diagram 的 code 版


回复

使用道具 举报

8

主题

0

好友

36

积分

初级会员

Rank: 1

8#
发表于 2010-3-4 06:12 PM |只看该作者

回复 #6 宅男-兜着走 的帖子

是的 ,  我就是 不太明白 method 应该怎么写, 我 是半路加进班的,所以method 不太明白怎么写。

请赐教!谢谢


回复

使用道具 举报

8

主题

0

好友

36

积分

初级会员

Rank: 1

9#
发表于 2010-3-4 06:22 PM |只看该作者
我是半路加进班的, 所以基础 的东西不太明白, 请大家指点一下method怎么写, 尤其是开头,请赐教开始的几个method怎么写。之后我会自己努力的。   

感谢大家来看我的帖子。


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

10#
发表于 2010-3-4 08:28 PM |只看该作者

回复 #9 Xis 的帖子

你自己思考下吧。

customOperation.java



  1. class CustomOperation {

  2. // method 里面能 code 你的东西。 如果你再不会的话。 拜托你从基本的java 开始学起。

  3. public int AddNumber(int num1 , int num2){
  4. return num1 + num2;
  5. }

  6. public bool IsZero(int num){
  7. return num == 0;
  8. }

  9. public int MulNumber(int num1, int num2){
  10. return num1 * num2;
  11. }

  12. }

复制代码


main.java



  1. public class testing{

  2. public static void main(string[] args){


  3. CustomOperation co = new CustomOperation(); // 你可以declare 先。

  4. int result = co.AddNumber(10 , 10);
  5. // output 是20

  6. if(co.isZero(result)){
  7. System.out.println("this result is zero");
  8. }
  9. // testing 看看 call is zero method , 如果是 0 , 那么就会return true

  10. int mulResult = co.MulNumber(1 , 20);
  11. // output 是20

  12. }

  13. }

复制代码


其实说到来, 这个也不算什么基本。


http://java.sun.com/docs/books/tutorial/java/javaOO/methods.html

同样的问题, 很多人都问过了。有时你应该自己上 google 查查看。

PS: 可能会有 syntax 的 error , 因为我现在没篇写工具 ==

[ 本帖最后由 宅男-兜着走 于 2010-3-4 08:32 PM 编辑 ]


回复

使用道具 举报

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

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-11-25 05:49 PM , Processed in 0.106712 second(s), 28 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部