Cricket task

  1. Create a class called Cricket
  2. Have below method in it. public int calculate(int balls) { return balls * 6; }
  3. Create one more class called ‘Player1’
  4. Have main method in it.
  5. Now, create instance for ‘Cricket’ class.
  6. Using instance, call calculate() method with 10 as argument.
  7. Now, store the returned result as score.
  8. print the score.

public class Cricket {

 public int calculate(int balls)
    {
   //System.out.println("gugan ball");
    return balls * 6; 
    }

Enter fullscreen mode Exit fullscreen mode

}

public class Player1 {
public static void main(String[] args) {
Cricket gugan = new Cricket();
int balls = gugan.calculate(10);

     System.out.println(balls);
}

Enter fullscreen mode Exit fullscreen mode

}

原文链接:Cricket task

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容