0

我来自俄罗斯。而且英语不是我的母语 :) 我试图理解这项任务,但我不能确保我正确理解它。

请纠正我。

http://pastie.org/1811424

class DE_Roman
{
   private String romanValue;
   private int    intValue;

   public void romanToInt(Strin romanValue)
   {
      this.romanValue = romanValue;

      int result;
      // ...
      // convert to int and save result in result variable

      this.intValue = result;
   }

   public void intToRoman(int intValue)
   {
      this.intValue = intValue;

      String result = "";
      // ...
      // convert to int and save result in result variable
      this.romanValue = result;
   }

   public void println()
   {
      System.out.println( this.toString() );
   }   

   public String toString()
   {
      return romanValue + " " + intValue;
   }
}

这是对的吗????

关于getInput我不明白......什么和在哪里......

4

1 回答 1

0

轻微偏差:

  1. 方法romanToInt应该被调用convertRomanToInt
  2. 方法intToRoman应该被调用convertIntToRoman
  3. 认为您应该实施一种isValid方法(第 7 项任务中的英语不好...)

其他一些要求涉及第二个类DE_RomanTester,并且该类应实现一个public static String getInput(String type)方法。该字符串告诉提示输入罗马字符或整数输入。他们没有说String类型应该是什么样子,所以这应该可以工作:

 public static final String ROMAN_TYPE   = "String";
 public static final String INTEGER_TYPE = "int";
 public static String getInput(String type) {
   if (type.equals(ROMAN_TYPE)) {
      // prompt for roman number, return int value (as String)
   } else if (type.equals(INTEGER_TYPE)) {
      // prompt for integer number, return roman value (as String)
   }
 }
于 2011-04-20T14:41:09.700 回答