class PlayGround
{
    int score,balls,catches;
    String player_name;

    public PlayGround(String player_name,int score,int catches)
    {
        this.score = score;
        this.player_name = player_name;
        this.catches = catches;
    }
    public PlayGround(String player_name,int score,int catches,int balls)
    {
        this.score = score;
        this.balls = balls;
        this.catches = catches;
        this.player_name = player_name;
    }

    public static void main(String [] args)
    {
        PlayGround player1 = new PlayGround("dhoni",100,3);
        PlayGround player2 = new PlayGround("jadeja",56,2,30);

        player1.batting();
        player2.allrounder();
    }
    public void batting()
    {
    System.out.println(player_name +" "+ score);
    }
    public void allrounder()
    {
    System.out.println(player_name + " " + balls + " " + score + " " + catches);
    }
}


登录后复制

输出:

以上就是日问2的详细内容,更多请关注慧达安全导航其它相关文章!

点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部