我错过了什么?没有显示输出

时间:2016-09-14 03:17:44

标签: javascript java

//Q1.7
class Toing {

  public static void main(String [] args){
    
  }
    public int distance(int sq1,int sq2){
     int x1 = sq1%8;
     int y1 = sq1/8;
     int x2 = sq2%8;
     int y2 = sq2/8;
     double a = Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    
     if(a % Math.sqrt(2) >= 1.41 && a % Math.sqrt(2) <= 1.42){
       return (int) (Math.round(a/Math.sqrt(2)));
     }
     else if(sq2 == sq1){
       return 0;
     }
     else {
       return (int)a;
     }
   }
  //Q1.8
    public boolean sameColumn(int sq1,int sq2) {
      return ((sq2 - sq1) % 8 == 0);
    }
 }

enter image description here

您好,有人可以帮助我,如果我在执行这些问题时遇到任何问题,就像我运行命令一样,它只会显示“Run Toing”。它是假设显示答案还是我们只需要代码?因为这个问题是关于移动等,例如

Q.1.7)距离(0,63)=&gt; 6。当我运行命令show 6时我的输出应该吗? Q.1.8)sameColumn(10,12)=&gt; true。运行命令时我的输出应该显示为true吗?

如果是的话,我错过了将它写在我的命令上,因为我今天写的东西太多了,因为我今天写了太多的东西......我只想和你们一起检查是否有人可以提供帮助,因为我没有那个人知道java ..谢谢

2 个答案:

答案 0 :(得分:0)

要离开,你需要运行该程序。现在string selectedProduct = lstCart.SelectedItem.ToString(); int selectedProductIndex = Array.IndexOf(products, selectedProduct); double selectedProductPrice = prices[selectedProductIndex]; totalPrice = totalPrice - selectedProductPrice; 是空的,什么都不做。 以下是使用main对象的示例:

Toing

答案 1 :(得分:0)

你的主要方法是空的,因此应用程序是好的设计但什么都不做..

如果要在控制台中看到某些输出,请使用System.out.println()方法

在您的情况下,您需要Toing

类的实例

这样做:

public static void main(String [] args){

  Toing myToingInstance = new Toing();

  int distance = myToingInstance.distance(0,63);
  System.out.println(" Tchebychev distance from 0 to 63 is: "+ distance);
}