Java Programming, Loose-Leaf Version
9th Edition
ISBN: 9781337685900
Author: FARRELL, Joyce
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 10, Problem 6PE
Program Plan Intro
Base ball game
Program plan:
Filename: “DemoBaseballGame.java”
- Include the required header files
- Define the class “DemoBaseballGame”
- Define the main method
- Create an object for “BaseballGame” class
- Call the method “SetNames” for setting the names
- Call the method “display”
- Call the “setScore” method for setting the score
- After setting the score, call the “display” method
- Call the “setScore” method in fifth inning
- Call the “setScore” method after setting second inning
- Call the “setScore” method for invalid inning
- Call the “setScore” method for invalid team
- Iterate the “t” value until it reaches “2”
- Iterate the “i” value until it reaches “getInnings”
- Call the “setScore” method
- Iterate the “i” value until it reaches “getInnings”
- Call the “display” method
- Define the “display” method
- Declare the required variables
- Display the teams
- Iterate the “t” value until it reaches “2”
- Iterate the “i” value until it reaches “getInnings”
- Call the “getScore” method
- Check “score” is not equal to “BaseballGame.UNPLAYED”
-
- Check the “i” is equal to 0
- Display the team
- Display the score
- Calculate the total score
-
- Set the value
-
- Check the “i” is equal to 0
- Iterate the “i” value until it reaches “getInnings”
- Check the condition
- Display no innings played yet
- Check the condition
- Check “total[0]” is greater than “total[1]”
- Display the winning name
- Otherwise, check “total [0]” is less than “total [1]”
- Display the winning name
- Otherwise, display game is tie.
- Check “total[0]” is greater than “total[1]”
- Define the main method
Filename: “BaseballGame.java”
- Define the “BaseballGame” class
- Declare the required variables
- Define the constructor
- Declare an array variable
- Iterate “t” until it reaches “scores” length
- Iterate “i” until it reaches “scores [t]” length
- Set the value
- Iterate “i” until it reaches “scores [t]” length
- Define the “setNames” method
- Set the values
- Define the “setScore” method
- Declare the required variables
- Check “team” is less than 0 or greater than “scores” length minus 1
- Display the team is valid
- Check “inning” is less than 0 or greater than “scores” length minus 1
- Display the team is not valid
- Otherwise,
- Iterate “x” until it reaches “inning”
- Check the condition
-
- Set the value
- Check the condition
- Display a score can’t yet be set for inning
- Otherwise, set the value
- Iterate “x” until it reaches “inning”
- Define the “setNames” method
- Return the names
- Define the “getNames” method
- Return the position of the name
- Define the “getScores” method
- Declare the variable
- Check “team” is less than 0 or greater than “scores” length minus 1
- Display invalid team number
- Check “inning” is less than 0 or greater than “scores[0]” length minus 1
- Display invalid inning
- Otherwise, set the value
- Define “getInnings” method
- Return innings
Filename: “HighSchoolBaseballGame.java”
- Declare the variable and assign the value
- Define the constructor
- Declare the array variable
- Iterate “t” until it reaches “scores” length
- Iterate “i” until it reaches “scores[t]” length
- Set the value
- Iterate “i” until it reaches “scores[t]” length
- Define “getInnings” method
- Return innings
Filename: “LittleLeagueBaseballGame.java”
- Declare the variable and assign the value
- Define the constructor
- Declare the array variable
- Iterate “t” until it reaches “scores” length
- Iterate “i” until it reaches “scores[t]” length
- Set the value
- Iterate “i” until it reaches “scores[t]” length
- Define “getInnings” method
- Return innings
Filename: “DemoLLBaseballGame.java”
- Include the required header files
- Define the class “DemoLLBaseballGame”
- Define the main method
- Create an object for “LittleLeagueBaseballGame” class
- Call the method “SetNames” for setting the names
- Call the method “display”
- Call the “setScore” method for setting the score
- After setting the score, call the “display” method
- Call the “setScore” method in fifth inning
- Call the “setScore” method after setting second inning
- Call the “setScore” method for invalid inning
- Call the “setScore” method for invalid team
- Iterate the “t” value until it reaches “2”
- Iterate the “i” value until it reaches “getInnings”
- Call the “setScore” method
- Iterate the “i” value until it reaches “getInnings”
- Call the “display” method
- Define the “display” method
- Declare the required variables
- Display the teams
- Iterate the “t” value until it reaches “2”
- Iterate the “i” value until it reaches “getInnings”
- Call the “getScore” method
- Check “score” is not equal to “BaseballGame.UNPLAYED”
-
- Check the “i” is equal to 0
- Display the team
- Display the score
- Calculate the total score
-
- Otherwise, set the value
-
- Check the “i” is equal to 0
- Iterate the “i” value until it reaches “getInnings”
- Check the condition
- Display no innings played yet
- Check the condition
- Check “total[0]” is greater than “total[1]”
- Display the team 1 is win
- Otherwise, check “total [0]” is less than “total [1]”
- Display the team 2 is win
- Otherwise, display game is tie.
- Check “total[0]” is greater than “total[1]”
- Define the main method
Filename: “DemoHSBaseballGame.java”
- Include the required header files
- Define the class “DemoHSBaseballGame”
- Define the main method
- Create an object for “HighSchoolBaseballGame” class
- Call the method “SetNames” for setting the names
- Call the method “display”
- Call the “setScore” method for setting the score
- After setting the score, call the “display” method
- Call the “setScore” method in fifth inning
- Call the “setScore” method after setting second inning
- Call the “setScore” method for invalid inning
- Call the “setScore” method for invalid team
- Iterate the “t” value until it reaches “2”
- Iterate the “i” value until it reaches “getInnings”
- Call the “setScore” method
- Iterate the “i” value until it reaches “getInnings”
- Call the “display” method
- Define the “display” method
- Declare the required variables
- Display the teams
- Iterate the “t” value until it reaches “2”
- Iterate the “i” value until it reaches “getInnings”
- Call the “getScore” method
- Check “score” is not equal to “BaseballGame.UNPLAYED”
-
- Check the “i” is equal to 0
- Display the team
- Display the score
- Calculate the total score
-
- Otherwise, set the value
-
- Check the “i” is equal to 0
- Iterate the “i” value until it reaches “getInnings”
- Check the condition
- Display no innings played yet
- Check the condition
- Check “total[0]” is greater than “total[1]”
- Display the team 1 is win
- Otherwise, check “total [0]” is less than “total [1]”
- Display the team 2 is win
- Otherwise, display game is tie.
- Check “total[0]” is greater than “total[1]”
- Define the main method
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Of the five primary components of an information system (hardware, software, data, people, process), which do you think is the most important to the success of a business organization?
Part A - Define each primary component of the information system.
Part B - Include your perspective on why your selection is most important.
Part C - Provide an example from your personal experience to support your answer.
Management Information Systems
Q2/find the transfer function C/R for the system shown in the figure
Re
ད
Chapter 10 Solutions
Java Programming, Loose-Leaf Version
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please original work select a topic related to architectures or infrastructures (Data Lakehouse Architecture). Discussing how you would implement your chosen topic in a data warehouse project Please cite in text references and add weblinksarrow_forwardPlease original work What topic would be related to architectures or infrastructures. How you would implement your chosen topic in a data warehouse project. Please cite in text references and add weblinksarrow_forwardWhat is cloud computing and why do we use it? Give one of your friends with your answer.arrow_forward
- What are triggers and how do you invoke them on demand? Give one reference with your answer.arrow_forwardDiscuss with appropriate examples the types of relationships in a database. Give one reference with your answer.arrow_forwardDetermine the velocity error constant (k,) for the system shown. + R(s)- K G(s) where: K=1.6 A(s+B) G(s) = as²+bs C(s) where: A 14, B =3, a =6. and b =10arrow_forward
- • Solve the problem (pls refer to the inserted image)arrow_forwardWrite .php file that saves car booking and displays feedback. There are 2 buttons, which are <Book it> <Select a date>. <Select a date> button gets an input from the user, start date and an end date. Book it button can be pressed only if the start date and ending date are chosen by the user. If successful, it books cars for specific dates, with bookings saved. Booking should be in the .json file which contains all the bookings, and have the following information: Start Date. End Date. User Email. Car ID. If the car is already booked for the selected period, a failure message should be displayed, along with a button to return to the homepage. In the booking.json file, if the Car ID and start date and end date matches, it fails Use AJAX: Save bookings and display feedback without page refresh, using a custom modal (not alert).arrow_forwardWrite .php file with the html that saves car booking and displays feedback. Booking should be in the .json file which contains all the bookings, and have the following information: Start Date. End Date. User Email. Car ID. There are 2 buttons, which are <Book it> <Select a date> Book it button can be pressed only if the start date and ending date are chosen by the user. If successful, book cars for specific dates, with bookings saved. If the car is already booked for the selected period, a failure message should be displayed, along with a button to return to the homepage. Use AJAX: Save bookings and display feedback without page refresh, using a custom modal (not alert). And then add an additional feature that only free dates are selectable (e.g., calendar view).arrow_forward
- • Solve the problem (pls refer to the inserted image) and create line graph.arrow_forwardwho started the world wide webarrow_forwardQuestion No 1: (Topic: Systems for collaboration and social business The information systems function in business) How does Porter's competitive forces model help companies develop competitive strategies using information systems? • List and describe four competitive strategies enabled by information systems that firms can pursue. • Describe how information systems can support each of these competitive strategies and give examples.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY