【问题标题】:describe the task描述任务
【发布时间】:2011-04-20 14:23:21
【问题描述】:

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

请纠正我。

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 我不明白......什么和在哪里......

【问题讨论】:

  • 欢迎来到 Stack Overflow,@johnson!我们的系统包含一个功能强大、易于使用的文本/代码格式化程序。查看概览here;通过单击每个帖子条目/编辑框右上角的颜色鲜艳的问号图标可以访问该页面。请在以后的帖子中使用格式化程序,以便我们更容易理解您的问题并为您提供帮助。我会为你修好这个。 (实际上,看起来@justkt 在我写这篇文章时为你做了。)
  • 这是作业吗?您是在询问您的程序是否与链接中的任务描述相匹配?
  • 关于任务:类似的。我试图理解这两个类的功能。

标签: java roman-numerals


【解决方案1】:

轻微偏差:

  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)
   }
 }

【讨论】:

  • @johnson - 还没有完成;)
猜你喜欢
  • 2012-02-05
  • 2020-07-04
  • 1970-01-01
  • 1970-01-01
  • 2015-03-03
  • 2017-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多