- Create a class called Cricket
- Have below method in it.
public int calculate(int balls)
{
return balls * 6;
}
- Create one more class called 'Player1'
- Have main method in it.
- Now, create instance for 'Cricket' class.
- Using instance, call calculate() method with 10 as argument.
- Now, store the returned result as score.
- print the score.
public class Cricket {
public int calculate(int balls)
{
//System.out.println("gugan ball");
return balls * 6;
}
}
public class Player1 {
public static void main(String[] args) {
Cricket gugan = new Cricket();
int balls = gugan.calculate(10);
System.out.println(balls);
}
}
The above is the detailed content of Cricket task. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn