Project #43764 - TWO Java homework

TWO JAVA HOMEWORK

 

Homework 1:

 

A Game of Basketball

 

Objective:

 

Write a two classes that simulates a score tracker in basket ball

  • First down load the Lab13 driver and put it in your project
  • Write a class file called Team that DOES NOT HAVE a main method
  • Some of the attributes of Team is
    • Name
    • Score
  • Some methods of Team are
    • Score 1 point
    • Score 2 points
    • Score 3 points
  • Also create accessors and mutators for each of the attributes
  • Next create another class called Game that DOES HAVE NOT a main method
  • This class should a method Start() that
    • Creates two teams
    • Prompt the user to name team 1 then team 2
    • While the game is not over, ask the user to enter a score
    • Based on what the user entered it will call a method that will update that team’s score (IE a 2 gives team A 2 points).
      • It may be a good idea to write a method that takes in the Team as a parameter and then asks the user for the score.
      • Then it will call the function of that team to update their score
    • Then the program should display the score of each team and who is winning.  Another place where a method can be used to compare the teams and print out a result.
    • Once the user enters Over, the game is over and the program stops

 

HINT!!!

In my Game.java file I use the following methods

·         Start()

·         ShowScore(Team t)

·         AssignPoitns(Team t)

·         CurrentWinningTeam(Team a, Team b)

 

 

Example Dialog:

 

Welcome to a game of basket ball

Enter the name for team 1

cats

 

Enter the name for team 2

cheezeburgers

 

Enter the team (either a or b) and a score.  Or enter 'over' to end the game

a 2

 

Team cats has 2 Points

Team cheezeburgers has 0 Points

cats is winning

 

Enter the team (either a or b) and a score.  Or enter 'over' to end the game

b 3

Team cats has 2 Points

Team cheezeburgers has 3 Points

cheezeburgers is winning

 

Enter the team (either a or b) and a score.  Or enter 'over' to end the game

a 1

Team cats has 3 Points

Team cheezeburgers has 3 Points

They are tied!!!

 

Enter the team (either a or b) and a score.  Or enter 'over' to end the game

a 5

Invalid Score!

Team cats has 3 Points

Team cheezeburgers has 3 Points

They are tied!!!

 

Enter the team (either a or b) and a score.  Or enter 'over' to end the game

over

The game is over

Team cats has 3 Points

Team cheezeburgers has 3 Points

They are tied!!!

Finally:

Upload Team.java and Game.java file to the dropbox

 

LAB13 Driver

public class BasketBallGameMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Game g = new Game();
		g.Start();
	}

}









Homework 2:




Happy Hour

 

Objective: 

Write a class called Beer in which it follows this format:

  • Instance Variables
    • Name
    • Alcohol content.  Beer is around 0.05 or 5%
  • Methods
    • Accessors and Mutators for the instance variables
      • Make sure in the mutator for the alcohol content contains a check to make sure the value is between 0 and 1 exclusively.
    • Intoxicated
      • Takes in a parameter of type double corresponding to weight
      • Calculates the number of drinks required to make a person intoxicated based on this formula (0.08 + 0.015) x Weight / (12 x 7.5 x Alcohol)
      • Returns the number of beers it would take before they are intoxicated

Next write another class

  • Contains a main method
  • Creates two instances of the type Beer
  • Have the user enter in the names and alcohol contents for both
  • Next enter in a weight value and it calculates how many drinks it would take for a person at that weight to become intoxicated
  • Print out the results

 

Example Output:

 

Let’s Party! Responsibly...

What’s the name of the first beer?

Pabst Blue Hipster

What’s the alcoholic content?

0.05

What’s the name of the second beer?

Moo Brew

What’s the alcoholic content?

0.08

What’s the weight of the person consuming said beverages?

150

It would take 3.166 Pabst Blue Hipster beers to become intoxicated.

It would take 1.979 Moo Brew beers to become intoxicated.

Later Tater

 





Subject Computer
Due By (Pacific Time) 10/15/2014 11:30 pm
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy