DEV Community

V I N O T H
V I N O T H

Posted on

1

Day10 Task

  1. Create a class Called PlayGround
  2. Create non-static variables as below. int score, balls, catches; String player_name;
  3. Create main method.
  4. Inside main method, create two instances as below. PlayGround player1 = new PlayGround("dhoni", 100, 3); PlayGround player2 = new PlayGround("jadeja", 56, 2, 30);
  5. Create appropriate constructors for handling above objects.
  6. Using player1 object, call batting() method. Print - score, player_name.
  7. Using player2 object, call allrounder() method. Print - score, player_name, balls, catches

Input:

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.player_name = player_name;
this.balls = balls;
this.catches = catches;
}
public static void main(String[] args)
{
Playground player1 = new Playground("dhoni",100,3);
Playground player2 = new Playground("jadeja",56,2,30);

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

Output:

Image description

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

đź‘Ą Ideal for solo developers, teams, and cross-company projects

Learn more