Topic: 紧急的问题,请高手们解释(理解英語題目)

  Print this page

1.紧急的问题,请高手们解释(理解英語題目) Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-17 20:44

请尽量使用准确的文字描述作为标题
原來的标题:
紧急的问题,请高手们解释


关于这个问题的,希望高手们解释这个题目到底要我做什么。

This question checks your ability to write the methods as described below. It tests your ability to use System.out.println() method, and to change the values of instance variables inside "mutator" methods.

The Copier needs developing to do some copying! A method to do this (i.e. to simulate it by taking in a string and outputting it to the terminal window) is added. A further, rather clumsy method, to make multiple copies is also added.

Make a new version of your Copier project and edit the Copier class so that it has the following additional methods.

public int makeCopy(String s)
that takes a String as a parameter, and outputs it on a single line to the terminal window. It should also increment (add 1 to) the total number of copies made, and return this as an int, and decrement (subtract 1 from) the number of sheets of paper available.
public int make5Copy(String s)
that takes a String as a parameter and outputs it on five successive single lines to the terminal window. It should also increase the total number of copies made by 5, and return this total as an int, and reduce the number of sheets available by 5.
cp03 testing code
The code used to test the Copier Class also uses methods written in previous assessments:

Copier c = new Copier();
c.testCopier();
if (c.makeCopy("makeCopy Works") == 1) {
System.out.println("and registers copies made");
}
else {
System.out.println("but doesn't register copies made correctly");
}
if (c.make5Copy("makeCopy Works") == 6) {
System.out.println("and registers copies made");
}
else {
System.out.println("but doesn't register copies made correctly");
}
When the code is run, the output to the Terminal Window should be the lines:

Copier Working
makeCopy Works and registers copies made
makeCopy Works
makeCopy Works
makeCopy Works
makeCopy Works
makeCopy Works and registers copies made

2.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 00:04

请不要無聊地"自己顶上去"!Angry

告訴我們閣下有啥不明白--總不能要人給閣下全篇翻譯吧

"Make a new version of your Copier project" 然則閣下已有一個 Copier project (和 java class)...
現在要閣下加上那兩個method

3.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 00:26

我现在就是不懂他要求我干什么,我之前是做了个Copier project

我给你看看:

/**
* Write a description of class Copier here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.awt.*;
public class Copier{
private int Copies=0;
private int Sheets=10;
public void Coier(int getSheetsPaper, int getCopies){
Sheets=getSheetsPaper;
Copies=getCopies;

}
public static void testCopier() {
System.out.println("Copier Working");
}
public int getCopies() {
return Copies;
}
public int getSheetsPaper() {
return Sheets;
}

}


还有怎么做的一个思路。因为我是新手,请指教


請善用修改功能

4.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 00:32

沒看見嗎?總不能要人給閣下全篇翻譯
請閣下先盡力把閣下能理解的說出來,或者指出閣下完全不明白的部分

如果經過努力也搞不懂這樣的英語的話,敝人不知道閣下怎可能用英語的教程學習下去,不如另想辦法好了.

5.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 00:43

我写了这个:

import java.awt.*;
public class Copier{
private int Copies=0;
private int Sheets=10;
public void Coier(int getSheetsPaper, int getCopies){
Sheets=getSheetsPaper;
Copies=getCopies;

}
public int makeCopy(String s)
{

return Copies ;

}
public int make5Copy(String s){
return Sheets ;

}
public static void testCopier() {
Copier c = new Copier();
c.testCopier();
if (c.makeCopy("makeCopy Works") == 1) {
System.out.println("and registers copies made");
}
else {
System.out.println("but doesn't register copies made correctly");
}
if (c.make5Copy("makeCopy Works") == 6) {
System.out.println("and registers copies made");
}
else {
System.out.println("but doesn't register copies made correctly");
}

}
}

6.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 00:45

Comments:
Test 1 succeeeded (2 marks) :
The compilation was successful

Test 2 failed (exit code = 1) :
Exception in thread "main" java.lang.StackOverflowError
  at Copier.testCopier(Copier.java:22)
  at Copier.testCopier(Copier.java:22)
  at Copier.testCopier(Copier.java:22)
  at Copier.testCopier(Copier.java:22)
  at Copier.testCopier(Copier.java:22)
。。。。。
The output should have been:
Copier Working
makeCopy Works
and registers copies made
makeCopy Works
makeCopy Works
makeCopy Works
makeCopy Works
makeCopy Works
and registers copies made
This is what was actually produced:

7.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 00:51

public int makeCopy(String s)
that takes a String as a parameter, and outputs it on a single line to the terminal window. It should also increment (add 1 to) the total number of copies made, and return this as an int, and decrement (subtract 1 from) the number of sheets of paper available.

public int make5Copy(String s)
that takes a String as a parameter and outputs it on five successive single lines to the terminal window. It should also increase the total number of copies made by 5, and return this total as an int, and reduce the number of sheets available by 5.

请你解释一下,我是懂,但是就是不知道从那里入手

8.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 01:01


package net.cjsdn.why;

public class Copier {
  private int copies = 0; // 第一個字母小寫
  private int sheets = 10;

  public Copier() {
    // 用default的 copies 和 sheets
  }
  
  public Copier(int sheetsPaper, int copies) {
    // 不要用 getSheetsPaper 這様的名字做 parameter
    this.sheets = sheetsPaper;
    this.copies = copies;
  }

  public void testCopier() { // no need to make it static
    System.out.println("Copier Working");
  }

  public int getCopies() {
    return copies;
  }

  public int getSheetsPaper() {
    return sheets;
  }

  public int makeCopy(String s) { //takes a String as a parameter
    // outputs it on a single line to the terminal window.
    System.out.println(s);
    
    // also increment (add 1 to) the total number of copies made,
    copies++;
    
    // and decrement (subtract 1 from) the number of sheets of paper available.
    sheets--;

    // and return this as an int
    return copies;
  }
  
  public int make5Copy(String s) {
    //TODO do it yourself
    increase the total number of copies made by 5, and return this total as an int
    copies = copies + 5;
    
    return copies;
  }
  
  public static void main(String[] args) {
    Copier c = new Copier(); // need defualt constructor if "public void Coier" is corrected
    c.testCopier(); // not static
    if (c.makeCopy("makeCopy Works") == 1) {
      System.out.println("and registers copies made");
    } else {
      System.out.println("but doesn't register copies made correctly");
    }
    if (c.make5Copy("makeCopy Works") == 6) {
      System.out.println("and registers copies made");
    } else {
      System.out.println("but doesn't register copies made correctly");
    }
  }
}

9.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 01:06

正在看,,,谢谢~~
不是我不懂,基本java的我都懂~~但是我现在学的是bluej 的教材,还有那么教授,都不讲基础的,所以,一开始做就很郁闷~~

10.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 01:19

kof821117 wrote:
不是我不懂,基本java的我都懂~~但是我现在学的是bluej 的教材,还有那么教授,都不讲基础的,所以,一开始做就很郁闷~~

如果這樣簡單清楚直接的題目"不知道从那里入手",
很坦白說,敝人不知道閣下憑甚麼說"基本java的我都懂"
不知道閣下要人家怎樣"讲基础的"才不會教似乎缺乏自知之明的閣下郁闷.

唉,不懂就是不懂,人貴自知喔.

對了,不要期望以後有人會回應這類問題,敝人只是本著盡力幫忙新來的朋友一次才回應的.

11.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 01:35

谢谢你的教诲,我也明白也你的意思,我承认的自己的经验少,基本我学习java的时候没有下手去做,不管怎么样,谢谢你了,

12.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 02:31

是了,你还介意我问多一个问题吗?
你写的code是这样显示的: Copier Working
makeCopy Works
and registers copies made
and registers copies made

那么怎么才能让它这样显示:
Copier Working
makeCopy Works
and registers copies made
makeCopy Works
makeCopy Works
makeCopy Works
makeCopy Works
makeCopy Works
and registers copies made

-------------------------------
你不必再写code,只是给我指点一下,谢谢,

13.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 04:07

kof821117 wrote:
你不必再写code,只是给我指点一下,谢谢,

Dead
Dead
Dead
Dead
Dead
Dead
Dead
Dead
Dead
even I were a cat with nine lives, I would be all dead now.


"outputs it on five successive single lines to the terminal window"
"reduce the number of sheets available by 5"
If you don't know how to do so, either learn English or quit Java.



> 你收我为徒弟好不好,我java的实践经验很少啊~~~
>
> 以后你教教我,不是为了作业什么的,是传授你的经验的~~好不好~~
敝人可不打算英年早逝
蘭摧玉折
哲人其萎
(It is interesting that all these proverbs have the character 折 inside Smile

14.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 04:31

public class Copier
{
private int copies = 0;

private int sheets = 10;

public Copier() {
}

public Copier(int sheetsPager, int copies) {

this.sheets=sheetsPager;
this.copies=copies;


}
public void testCopier() {
System.out.println("Copier Working");

}
public int getsheetsPager(){

return sheets;
}
public int copies(){

return copies;
}
public int makeCopy(String s){
System.out.printlnMoon;

copies++;
sheets--;
return copies;

}
public int make5Copy(String s) {
  System.out.printlnMoon;
  System.out.printlnMoon;
  System.out.printlnMoon;
  System.out.printlnMoon;
  System.out.printlnMoon;
copies+=5;



return copies;

}


public static void main(String[] args) {
Copier c = new Copier();
c.testCopier();
if (c.makeCopy("makeCopy Works") == 1) {
System.out.println("and registers copies made");
} else {
System.out.println("but doesn't register copies made correctly");
}
if (c.make5Copy("makeCopy Works") == 6) {


System.out.println("and registers copies made");

} else {
System.out.println("but doesn't register copies made correctly");
}
}
}


呵呵,,还好,我还是懂的,

15.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 04:52

Please check "Disable Smileys" and use the [ code ] tag for better presentation of source code or other listing.

public int make5Copy(String s) {
/*
  System.out.println(s);
  System.out.println(s);
  System.out.println(s);
  System.out.println(s);
  System.out.println(s);
*/
for (int i = 0; i < 5; i++) {
System.out.println(s);
}

sheets -= 5; // you missed this

copies+=5;

return copies;
}

16.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 09:57

public int make5Copy(String s) {

copies+=5;
for(int i=1;i<copies;i++)
System.out.printlnMoon;
return copies;
}

用这个吧,,是不是啊~~大哥~~!!!

17.Re:紧急的问题,新的一个问题又来了,~~ [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 10:03

http://itsuite.it.brighton.ac.uk/jkw9/ci101Sem1/website/q04.htm

是之前的那个程序的升级版,,又要加一些东西进去,

declare a local boolean//声明当地boolean
assume false //假设是错的

if (there is paper left) // 没有纸了
make copy // 这个不懂什么“意思”
make boolean true 强制boolean为真值

return boolean // 返回值。

关于这个题的思路,我不是很了解,能给我解释吗?

18.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: kof821117
Posted on: 2006-01-18 10:07

Assignment 4: A more sensible multiple copy function
(NB this was edited on Nov 11 to add a further method and on Nov 21 to add pseudocode)

make5Copy is a very inflexible way of making multiple copies. In this exercise
the makeCopy method is to be modified to make it more useful,
and a method makeCopies added that uses makeCopy to make multiple copies
an addPaper method is added as well

N B. The accessor methods getCopies() and getSheetsPaper() already written in cp02 are used to check that the Copying methods are being registered and that the number of sheets is reduced by them.

Make a new copy of the project and edit the Copier class as follows, remembering to use exactly the same name for the methods.

edit your makeCopy() to return a boolean, not an int pseudocode might be
public boolean makeCopy(String text)
should return a boolean (true or false) value.
This should be true if the copy was possible, and false if not.
It should not be possible to make a copy if there is no paper left!
declare a local boolean
assume false

if (there is paper left)
make copy
make boolean true

return boolean

create a new method to make multiple copies:
public int makeCopies(String text, int number)
This should try to make as many copies of the string as are passed to it as number
(so makeCopies("test",7) should produce 7 copies).
It should use makeCopy() to actually produce the copy.
If makeCopy() returns the boolean false,
makeCopies() should itself return an int, the number of copies still to be done.
declare a local boolean
assume true

while (there are copies to be made && boolean is true)
boolean = return value of makeCopy

if boolean is true
decrement number to be made

end while

return number of copies to be made


create a new method to increase the paper available
public int addPaper ( int n )
This should add n sheets of paper to those available provided n>0
It should return the number of sheets then available.
if n>0
numberofSheets += n ;


Testing code
The code used to test the Copier Class also uses methods previously written in Assignment 2: Note that the Copier class should still initialise the number of sheets to 10.

Copier c = new Copier();
c.testCopier();
if (c.makeCopy("makeCopy Works")) {
System.out.println("and registers copies made");
} else {
System.out.println("but doesn't register copies made correctly");
}
if (c.makeCopies("makeCopies Works", 5) == 0) {
System.out.println("and registers copies made");
} else {
System.out.println("but doesn't register copies made correctly");
}
// line below changed (for consistency only) on 22 November; output changed to match.
System.out.println("adding 1 sheet of paper: now there are " + c.addPaper(1) );
if (c.makeCopies("makeCopies Works", 8) == 3) {
System.out.println("and registers copies made, ");
System.out.println("and that there are 3 left to make");
} else {
System.out.println("but doesn't register copies made correctly");
}
System.out.println("Copies made = " + c.getCopies());
System.out.println("Sheets left = " + c.getSheetsPaper());

This should produce the output:

Copier Working
makeCopy Works
and registers copies made
makeCopies Works
makeCopies Works
makeCopies Works
makeCopies Works
makeCopies Works
and registers copies made
adding 1 sheet of paper: now there are 5
makeCopies Works
makeCopies Works
makeCopies Works
makeCopies Works
makeCopies Works
and registers copies made,
and that there are 3 left to make
Copies made = 11
Sheets left = 0

19.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-18 10:11

public int make5Copy(String s) {

copies+=5;
for(int i=1;i<copies;i++)
System.out.println(s );
return copies;
}

What are you trying to do?
copies == number of copies made so far with this Copier.
Dead

> if (there is paper left) // 没有纸了
there is paper left == 还有纸Sad

> 思路,我不是很了解
The pseudo code should be clear enough, I won't waste more of my time on this.
I am serious:
If you don't know how to do this assignment, either learn English or quit Java.

如果閣下根本不明白題目的英語,為何要用這個教程??

20.Re:紧急的问题,请高手们解释(理解英語題目) [Re: kof821117] Copy to clipboard
Posted by: why
Posted on: 2006-01-25 12:14

Copier in Part 2 should look like this:

public class Copier {
private int copies;
private int sheets;

public Copier() {
//Initialise them in the Constructor method of Copier so that copies=0 and sheets=10;
copies = 0;
sheets = 10;
}

public int getCopies() {
return copies;
}

public int getSheetsPaper() {
return sheets;
}

void testCopier() {
System.out.println("Copier Working");
}
}


and then Part 3:

public class Copier {
private int copies;
private int sheets;

public Copier() {
//Initialise them in the Constructor method of Copier so that copies=0 and sheets=10;
copies = 0;
sheets = 10;
}

public int getCopies() {
return copies;
}

public int getSheetsPaper() {
return sheets;
}

void testCopier() {
System.out.println("Copier Working");
}

public int makeCopy(String s) { //takes a String as a parameter
// outputs it on a single line to the terminal window.
System.out.println(s);

// also increment (add 1 to) the total number of copies made,
copies++;

// and decrement (subtract 1 from) the number of sheets of paper available.
sheets--;

// and return this as an int
return copies;
}

public int make5Copy(String s) {
for (int i = 0; i < 5; i++) {
System.out.println(s);
}
copies += 5;
sheets -= 5;

return copies;
}

}


and Part 4:

public class Copier {
private int copies;
private int sheets;

public Copier() {
//Initialise them in the Constructor method of Copier so that copies=0 and sheets=10;
copies = 0;
sheets = 10;
}

public int getCopies() {
return copies;
}

public int getSheetsPaper() {
return sheets;
}

void testCopier() {
System.out.println("Copier Working");
}

public int addPaper(int n) {
if (n > 0) {
sheets += n;
}

return sheets;
}

public boolean makeCopy(String text) {
boolean isCopyMade = false;

if (sheets > 0) { // there is paper left
System.out.println(text);
copies++;
sheets--;
isCopyMade = true;
}

return isCopyMade;
}

public int makeCopies(String text, int number) {
boolean continueCopy = true;

while (number > 0 && continueCopy) {
continueCopy = makeCopy(text);

if (continueCopy) {
number--;
}
}

return number;
}

public int make5Copy(String s) {
for (int i = 0; i < 5; i++) {
System.out.println(s);
}
copies += 5;
sheets -= 5;

return copies;
}

}


I just want to show you that the pseudo code in the question is clear enough, and the solution is very straight-forward, as long as you understand it.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923