Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 3, Problem 38E
Program Plan Intro
To change the clock from a 24-hour clock to a 12-hour clock
Program Plan:
  Modify a program in BlueJ using Java and achieve the 12-hour clock. The clock should display the midnight and afternoon time as 12:30 and not as 00:30. The minute should be displaying values from 0 to 59 and the hour should be displaying values from 1 to 12.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
creating a roulette wheel. The pockets are numbered from 0 to 36. The colors of the pockets are as follows:
Pocket 0 is green.
For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered pockets are black.
For pockets 11 through 18, the odd-numbered pockets are black and the even-numbered pockets are red.
For pockets 19 through 28, the odd-numbered pockets are red and the even-numbered pockets are black.
For pockets 29 through 36, the odd-numbered pockets are black and the even-numbered pockets are red.
Create a class named RoulettePocket. The class's constructor should accept a pocket number. The class should have a method named getPocketColor that returns the pocket's color, as a string.
Demonstrate the class in a program that asks the user to enter a pocket number, and displays whether the pocket is green, red, or black. The program should display an error message if the user enters a number that is outside the range of 0 through 36.
I need the answer as soon as possible
The goal of Snake is to create a snake as long as possible. This is achieved by guiding the snake to an apple on the game board. The snake cannot stop moving, and dies whenever it hits something (excluding apples). Because the snake is growing longer and longer as the game progresses, it gets increasingly difficult to avoid collisions with the snake itself. The player can change the direction of the head of the snake by using the arrow keys. At step in the game, there is always an apple somewhere on the board. If the snake eats an apple, the snake becomes one cell longer. A new apple is placed on a random location, excluding all places covered by the snake. When the snake reaches a side of the game board, it re-emerges at the opposite end.
Chapter 3 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 3 - Prob. 1ECh. 3 - At what time (s) can a class diagram change? How...Ch. 3 - At what time(s) can an object diagram change? How...Ch. 3 - Write a definition of a field named tutor that can...Ch. 3 - Prob. 5ECh. 3 - Create a second NumberDisplay object with a limit...Ch. 3 - Select Show Code Pad from the View menu. Create a...Ch. 3 - What error message do you see in the Code Pad if...Ch. 3 - What error message do you see in the Code Pad if...Ch. 3 - What happens when the setValue method is called...
Ch. 3 - Prob. 11ECh. 3 - Prob. 12ECh. 3 - Which of the following expressions return...Ch. 3 - Write an expression using boolean variables a and...Ch. 3 - Write an expression using boolean variables a and...Ch. 3 - Consider the expression (a && b). Write an...Ch. 3 - Does the getDisplayValue method work correctly in...Ch. 3 - Prob. 18ECh. 3 - In Exercise 2.79 you were asked to investigate...Ch. 3 - Explain the modulo operator. You may need to...Ch. 3 - What is the result of the expression 83?Ch. 3 - Try out the expression in the Code Pad. Try other...Ch. 3 - Prob. 23ECh. 3 - Prob. 24ECh. 3 - Explain in detail how the increment method works.
Ch. 3 - Rewrite the increment method without the modulo...Ch. 3 - Open the clock-display project and create a...Ch. 3 - Prob. 28ECh. 3 - Prob. 29ECh. 3 - Prob. 30ECh. 3 - Look at the second constructor in C1ockDisplay's...Ch. 3 - Prob. 32ECh. 3 - Given a variable Printer p1; which currently holds...Ch. 3 - Open the house project from Chapter 1 and review...Ch. 3 - Prob. 35ECh. 3 - Does the Picture class contain any internal method...Ch. 3 - Remove the following two statements from the draw...Ch. 3 - Prob. 38ECh. 3 - Prob. 39ECh. 3 - Assume a class Tree has a field of type Triangle...Ch. 3 - Prob. 41ECh. 3 - Open the mail-system project, which you can find...Ch. 3 - Prob. 43ECh. 3 - Prob. 44ECh. 3 - Open the editor for the MailClient class and set a...Ch. 3 - Step one line forward in the execution of the...Ch. 3 - Prob. 47ECh. 3 - Prob. 48ECh. 3 - Prob. 49ECh. 3 - Set a breakpoint in the first line of the sendMai1...Ch. 3 - Use a combination of code reading, execution of...Ch. 3 - Use the debugger to investigate the clock-display...Ch. 3 - Prob. 53ECh. 3 - Prob. 54ECh. 3 - Prob. 55ECh. 3 - Describe the changes that would be required to the...Ch. 3 - Write the code for the timeTick method in...Ch. 3 - Discuss whether the current design of the...Ch. 3 - Challenge exercise In the current design of...
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
- The game is played in the magic maze, as shown below. The squares are flaming lava pools. If you try to cross them you will die. The grid lines are passageways and are safe to travel in. You can start at any location on the grid but must travel in the passageways. You may travel as far as you want in any direction, but once you turn, you must repeat that distance and you may only make left turns. You may not reverse direction inside the tight passageways. You must end up at the same spot you started at. If you successful, then you gain a magic coin, which automatically appears. You can start over again and again in a different or same starting spot and earn new magic coins, but the routes you take must differ somehow for each magic coin. That is, no magic coins for the exact same route as previously done. If the route varies in any way (perhaps it is the same starting location and ending location as a previous route, but longer), it will earn a new magic coin. Mad Madame Mim has…arrow_forwardImplement the "Replace player" menu option. Prompt the user for the jersey number of the player to replace. If the player is in the roster, then prompt again for a new jersey number and rating. Update the replaced player's jersey number and rating.Ex: Enter a jersey number: 4 Enter a new jersey number: 12 Enter a rating for the new player: 8arrow_forwardMake a MAZE game on Spyder, giving the user to choose their route. Each route will have either doors or obstacles that the user will solve or use logic to complete. Use a random function so the obstacles change with a new try. The user needs to get out of the Maze in three tries or he loses a life. The user will be asked a question whether they want to try it again or skip the level. Need help with the code!! Thank youarrow_forward
- Four in a row is a game in which players take turns adding tokens to the columns on the game board. Tokens fall to the lowest position in the chosen column that does not already have a token in it. Once one of the players has placed four of their tokens in a straight line (either vertically, horizontally, or diagonally), they win the game If the board is full and no player has won, then the game ends in a draw. TASK Using the following class descriptions, create a UML diagram and a version of Four in a row game The game must allow for a minimum of two and maximum of four players The game must allow each player to enter their name(duplicate names should not be accepted) The game should give the players the ability to choose how many rows (between four and ten), and how many columns (between four and ten) the game board should have. The code uses several classes, including "Player", "Board","Game" and exceptions for handling errors such as invalid moves and full columns.…arrow_forwardThis challenge is based on the classic videogame "Snake". Assume the game screen is an n * n square, and the snake starts the game with length 1 (i.e. just the head) positioned on the top left corner. For example, if n = 7 the game looks something like this: BEGINNING In this version of the game, the length of the snake doubles each time it eats food (e.g. if the length is 4, after eating it becomes 8). Create a function that takes the siden of the game screen and returns the number of times the snake can eat before it runs out of space in the game screen. Examples FIRST MOVE snakefill (3) snakefill (6) - 5 snakefill (24) → 9 3arrow_forwardOBAFGKM are the seven categories that are used to describe the absorption lines of a spectrum. Access the Spectral Types Color Slider by opening the Eclipsing Binary Stars section of the NAAP Labs Application and then the Spectral Types of Stars subsection (it is the last simulation on the page) and use it to complete the data table below. Spectral Type: include a letter and a number (no space). Temperature: Kelvin (K) is assumed for Temperature. Color: choose from Blue, White, Orange, or Red (spelling counts!).arrow_forward
- In this task by using java language , you should create the moving box example belwo, then you should extend the box class and create a new one called ColoredBox, in this class you should override the drawing method, the first thing you should do is recalling the original draw method (as we don't want to change any of the previous behaviours), then you should check if the box collided on the X or Y axis, if so change the colour of the box randomly colour. o 3:53 / Now we have a fully functional animated box :D TV Screen D. Figure 2: TV Screen App.arrow_forwardImplement the "Delete player" menu option. Prompt the user for a player's jersey number. Remove the player from the roster (delete the jersey number and rating). Ex: Enter a jersey number: 4arrow_forwardCounting the growth rings of a tree is a good way to tell the age of a tree. Each growth ring counts as one year. Use a Canvas widget to draw how the growth rings of a 5-year-old tree might look. Then, using the create_text method, number each growth ring starting from the center and working outward with the age in years associated with that ring.arrow_forward
- Make Ice Cream In this challenge activity, you will analyze the numbered steps to make vanilla ice cream and translate them into inputs, actions, and outputs. Instructions to make vanilla ice cream: 1. Stir white sugar, heavy cream, and milk in a saucepan. Heat the mixture using low heat until the sugar is dissolved. Continue to heat until the mixture is hot, and a small ring of foam forms around the edge. 2. Transfer the mixture to a large container. Stir in vanilla extract. Chill the mixture for at least two hours. 3. Pour the cold mixture into an ice cream making machine. Churn the ice cream according to the machine directions. 4. When ready, serve the ice cream. Making Ice Cream Input Action Outputarrow_forwardWhen the player clicks on the “Start Game” button, in every 1 seconds, three random alphabets will be generated and flashing on the screen (e.g. A X W) at the position as shown above. The three alphabets must not repeat at the same time (i.e. can’t have repeating alphabets – e.g. A X A). After starting a game, you can’t change the chosen alphabet.arrow_forwardA number maze is an n × n grid of positive integers. A token starts in the upper left corner; your goal is to move the token to the lower-right corner. On each turn, you are allowed to move the token up, down, left, or right; the distance you may move the token is determined by the number on its current square. For example, if the token is on a square labeled 3, then you may move the token three steps up, three steps down, three steps left, or three steps right. However, you are never allowed to move the token off the edge of the board. 6 3574 5 315 3 283 35 74 6 53 15 1 4 2 8 3 1 4 4 5 7 2 3 4 5 7 2 3 3 1 3 2★ 3 KT3 A 5 × 5 maze that can be solved in eight moves In this problem, you will design and analyze an efficient algorithm that either returns the minimum number of moves required to solve a given number maze, or correctly reports that the maze has no solution. Describe the solution to this problem at a high level, justify why it works, write down the pseudocode for your algorithm…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education