登录
首页 >  文章 >  java教程

日问2

来源:dev.to

时间:2025-01-12 19:41:54 223浏览 收藏

哈喽!今天心血来潮给大家带来了《日问2》,想必大家应该对文章都不陌生吧,那么阅读本文就都不会很困难,以下内容主要涉及到,若是你正在学习文章,千万别错过这篇文章~希望能帮助到你!

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


输出:

image description

以上就是本文的全部内容了,是否有顺利帮助你解决问题?若是能给你带来学习上的帮助,请大家多多支持golang学习网!更多关于文章的相关知识,也可关注golang学习网公众号。

声明:本文转载于:dev.to 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>