Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help in my Java class. so my professor told me to do a lab but didn't tell me how to do it and

i need help in my Java class. so my professor told me to do a lab but didn't tell me how to do it and there is know way to study for it. i don't even understand what to even do. there are two parts for the lab. one is the baseballplayer and the other is the testBaseballplayer.

public class BaseballPlayer

{

private String playerName;

private String team;

private String position;

private int atBats;

private int hits;

}

testBaseballPlayer:

public class TestBaseballPlayer

{

public static void main(String[] args)

{

BaseballPlayer bb1 = new BaseballPlayer();

BaseballPlayer bb2 = new BaseballPlayer();

bb1.setPlayerName("Aaron Judge");

bb1.setTeam("Yankees");

bb1.setPosition("Right field");

bb1.setAtBats(3);

bb1.setHits(2);

bb2.setPlayerName("Miguel Andujar");

bb2.setTeam("Yankees");

bb2.setPosition("Third base");

bb2.setAtBats(3);

bb2.setHits(1);

System.out.println("Player 1 name: " + bb1.getPlayerName());

System.out.println("Player 1 team: " + bb1.getTeam());

System.out.println("Player 1 position: " + bb1.getPosition());

System.out.println("Player 1 at bats: " + bb1.getAtBats());

System.out.println("Player 1 hits: " + bb1.getHits());

System.out.println();

System.out.println("Player 2 name: " + bb2.getPlayerName());

System.out.println("Player 2 team: " + bb2.getTeam());

System.out.println("Player 2 position: " + bb2.getPosition());

System.out.println("Player 2 at bats: " + bb2.getAtBats());

System.out.println("Player 2 hits: " + bb2.getHits());

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions