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
Question
Chapter 2, Problem 38E
Program Plan Intro
Question reference:Â Refer to Chapter 2, Exercise 2.38 to modify the method named printTicket of the class TicketMachine.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
TYPEWRITTEN ONLY PLEASE UPVOTE. DOWNVOTE FOR HANDWRITTEN. DO NOT ANSWER IF YOU ALREADY ANSWERED THIS. THE BIG NUMBER IN THE SIDE IS FOR NUMBERING.
The lead singer, Harry Styles, wants to see his name printed every time his rule is run. Write out the action that will print the phrase Harry Styles to the terminal
Create a card game in which the dealer shuffles the deck and deals 13 cards to the player. The player sorts her hand and says whether it includes the King of Hearts. Repeat 4 times so all the cards are dealt eventually. Internally, the player should return true or false without writing to the console. In response, the dealer should write on the console, "You won!" or "You loose again."
Chapter 2 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 2 - Create a TicketMachine object on the object bench...Ch. 2 - What value is returned if you get the machine's...Ch. 2 - Prob. 3ECh. 2 - Prob. 4ECh. 2 - Create another ticket machine for tickets of a...Ch. 2 - Prob. 6ECh. 2 - Does it matter whether we write...Ch. 2 - Prob. 8ECh. 2 - Put back the word public, and then check whether...Ch. 2 - From your earlier experimentation with the ticket...
Ch. 2 - Prob. 11ECh. 2 - Prob. 12ECh. 2 - Prob. 13ECh. 2 - Prob. 14ECh. 2 - In the following field declaration from the...Ch. 2 - Prob. 16ECh. 2 - Prob. 17ECh. 2 - To what class does the following constructor...Ch. 2 - How many parameters does the following constructor...Ch. 2 - Prob. 20ECh. 2 - Suppose that the class Pet has a field called name...Ch. 2 - Challenge exercise The following object creation...Ch. 2 - Compare the header and body of the getBalance...Ch. 2 - If a call to getPrice can be characterized as...Ch. 2 - If the name of getBalance is changed to getAmount,...Ch. 2 - Prob. 26ECh. 2 - Try removing the return statement from the body of...Ch. 2 - Compare the method headers of getPrice and...Ch. 2 - Do the insertMoney and printTicket methods have...Ch. 2 - Create a ticket machine with a ticket price of...Ch. 2 - How can we tell from just its header that setPrice...Ch. 2 - Complete the body of the setPrice method so that...Ch. 2 - Prob. 33ECh. 2 - Is the increase method a mutator? If so, how could...Ch. 2 - Prob. 35ECh. 2 - Write down exactly what will be printed by the...Ch. 2 - Add a method called prompt to the TicketMachine...Ch. 2 - Prob. 38ECh. 2 - What about the following version?
Ch. 2 - Prob. 40ECh. 2 - Add a showPrice method to the TicketMachine class....Ch. 2 - Create two ticket machines with differently priced...Ch. 2 - Modify the constructor of TicketMachine so that it...Ch. 2 - Give the class two constructors. One should take a...Ch. 2 - Implement a method, empty, that simulates the...Ch. 2 - Prob. 46ECh. 2 - Predict what you think will happen if you change...Ch. 2 - Rewrite the if-else statement so that the method...Ch. 2 - Prob. 49ECh. 2 - In this version of printTicket, we also do...Ch. 2 - Is it possible to remove the else part of the...Ch. 2 - After a ticket has been printed, could the value...Ch. 2 - So far, we have introduced you to two arithmetic...Ch. 2 - Write an assignment statement that will store the...Ch. 2 - Write an assignment statement that will divide the...Ch. 2 - Prob. 56ECh. 2 - Modify your answer to the previous exercise so...Ch. 2 - Why does the following version of refundBalance...Ch. 2 - What happens if you try to compile the...Ch. 2 - What is wrong with the following version of the...Ch. 2 - Add a new method, emptyMachine, that is designed...Ch. 2 - Rewrite the printTicket method so that it declares...Ch. 2 - Challenge exercise Suppose we wished a single...Ch. 2 - List the name and return type of this method:
Ch. 2 - Prob. 65ECh. 2 - Write out the outer wrapping of a class called...Ch. 2 - Write out definitions for the following fields:
Ch. 2 - Write out a constructor for a class called Module....Ch. 2 - Prob. 69ECh. 2 - Correct the error in this method:...Ch. 2 - Write an accessor method called getName that...Ch. 2 - Write a mutator method called setAge that takes a...Ch. 2 - Write a method called printDetails for a class...Ch. 2 - Draw a picture of the form shown in Figure 2.3,...Ch. 2 - Prob. 75ECh. 2 - Create a Student with name "djb" and id "859012"....Ch. 2 - Prob. 77ECh. 2 - Challenge exercise Modify the getLoginName method...Ch. 2 - Consider the following expressions. Try to predict...Ch. 2 - Open the Code Pad in the better-ticket-machine...Ch. 2 - Now add the following in the Code Pad:...Ch. 2 - Add the following: t1.InsertMoney500; What would...Ch. 2 - Prob. 83ECh. 2 - Prob. 84ECh. 2 - Add a field, pages, to the Book class to store the...Ch. 2 - Are the Book objects you have implemented...Ch. 2 - Add a method, printDetails, to the Book class....Ch. 2 - Add a further field, refNumber, to the Book class....Ch. 2 - Modify your printDetai 1 s method to include...Ch. 2 - Prob. 90ECh. 2 - Add a further integer field, borrowed, to the Book...Ch. 2 - Prob. 92ECh. 2 - Prob. 93ECh. 2 - Prob. 94E
Knowledge Booster
Similar questions
- Correct answer will be upvoted else downvoted. You are playing the game "Orchestrating The Sheep". The objective of this game is to make the sheep line up. The level in the game is depicted by a line of length n, comprising of the characters '.' (void space) and '*' (sheep). In one action, you can move any sheep one square to the left or one square to the right, if the relating square exists and is vacant. The game finishes when the sheep are arranged, that is, there ought to be no vacant cells between any sheep. For instance, assuming n=6 and the level is depicted by the string "**.*..", the accompanying game situation is conceivable: the sheep at the 4 position moves to one side, the condition of the level: "**..*."; the sheep at the 2 position moves to one side, the condition of the level: "*.*.*."; the sheep at the 1 position moves to one side, the condition of the level: ".**.*."; the sheep at the 3 position moves to one side, the condition of the level: ".*.**.";…arrow_forwardPlease do it with comments.arrow_forwardcanMove(int x, int y, int destX, int destY, Side s): This method returns true if the player of color s can move the piece at coordinates (x,y) can move to coordinates (destX, destY) on the board in its current state. This means that here you do need to consider this piece’s interaction with other pieces on the board. Conditions for this method to return false are given in the code. public boolean canMove(int x, int y, int destX, int destY, Side s){ /* TODO write a method that checks if a piece at coordinates x,y can move to coordinates destX,destY Conditions for false: - Origin or destination coordinates are outside the board - Piece at origin is null - If source and destination coordinates are the same - Piece at origin is not of the same side as s - You can check this using piece.getSide() - Piece cannot move to the destination by piece movement rules - You should check this using Piece.canMove(destX,…arrow_forward
- https://youtu.be/4hAoK54Pfdc Here is a video regarding the kit component.arrow_forwardTake a look at the header of the method below, and then implement a sample call to it in your code.empty public ShowValue ()arrow_forwardIn this problem you will calculate the area of a house and compare it with another house to see which one is bigger. House1 vs. House2 We need to have a struct that has width and length in it. This struct represents a rectangular room. From room we need to define: Bathroom, Livingroom, Bedroom and Kitchen. An example of the struct and Bathroom, Livingroom, Bedroom and Kitchen is shown below. Also, it is shown how to set value of Bathroom Length and Width- values are assumed in feet. House area is in Square Feet (sqrft) and can be calculated by adding all room areas together in sqrft. Program example: Struct room { Length; Width: }; Struct room Bathroom1 , Livingroom1, Kitchen1, Bedroom1; Bathroom1.Length=10; Bathroom1.Width=7; Now Given: House1 is comprised of: Bedroom1 (L=15,W=10) Bathroom1 (L=10,W=7) Kitchen1(L=15, W= 10) Livingroom1 (L=25,W=20) House2 is comprised of: Bedroom2_1 (L=10, W=10) Bedroom2_2(L=10, W=12) Kitchen2(L=16,W=10) Livingroom2 (L=15,W=12) Calculate each House area…arrow_forward
- TYPEWRITTEN ONLY PLEASE FOR UPVOTE. DOWNVOTE FOR HANDWRITTEN. DO NOT ANSWER IF YOU ALREADY ANSWERED THIS. I'LL DOWNVOTE.arrow_forwardPlease help me create a cave class for a Hunt the Wumpus game (in java). You can read the rules in it's entirety of the Hunt the Wumpus game online to get a better idea of the specifications. It's an actual game. INFORMATION: The object of this game is to find and kill the Wumpus within a minimum number of moves, before you get exhausted or run out of arrows. There is only one way to win: you must discover which room the Wumpus is hiding in and kill it by shooting an arrow into that room from an adjacent room. The Cave The Wumpus lives in a cave of 30 rooms. The rooms are hexagonal. Each room has up to 3 tunnels, allowing access to 1, 2 or 3 (out of 6) adjacent rooms. The attached diagram shows the layout of rooms in the cave. The map wraps around such that rooms on the edges (white cells) have neighbors from the opposite edge (blue cells). E.g., the neighbors of room 1 are rooms 25, 26, 2, 7, 6, and 30, and you could choose to connect room 1 to any of these rooms. Observe how…arrow_forwardPlease show work in javaarrow_forward
- Program Specifications Write a FancyCar class to support basic operations such as drive, add gas, honk horn and start engine. fancy_car.py is provided with function stubs. Follow each step to gradually complete all instance methods. Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main program includes basic calls to the instance methods. Add statements in the main program as instance methods are completed to support development mode testing. **Step 0: Complete the constructor to initialize the model and miles per gallon (MPG) with the values of the parameters. Initialize the odometer to five miles and the tank to be full of gas. By default, the model is initialized to "Old Clunker", and MPG is initialized to 24.0. Note the provided constant variable indicates the gas tank capacity of 14.0 gallons. Step 1 Complete the instance…arrow_forward(This is for devc++ but I use mindmap from Cengage. I know it a little different. If you can't use Cengage, I suggest devc++ version 5.11) One way to determine how healthy a person is, is by measuring the body fat of the person. The formulas to determine the body fat for female and male are as follows: Body fat formula for women: A1 = (body weight X 0.732) + 8.987 A2 = wrist measurement (at fullest point) / 3.140 A3 = waist measurement (at navel) X 0.157 A4 = hip measurement (at fullest point) X 0.249 A5 = forearm measurement (at fullest point) X 0.434 B = A1 + A2 - A3 - A4 + A5 Body fat = body weight - B Body fat percentage = body fat X 100 / body weight Body fat formula for men: A1 = (body weight X 1.082) + 94.42 A2 = waist measurement X 4.15 B = A1 - A2 Body fat = body weight - B Body fat percentage = body fat X 100 / body weight Instructions Write a program to calculate the body fat of a person. Prompt the user to input: Their gender ('m' or 'M' for male, 'f' or 'F' for…arrow_forwardHelp, I tried to write what I could but I am not sure what to write next. The code need to include Poylmorphism of passenger and elevator. Any help would be appreciated. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. There are 4 types of elevators in the system:StandardElevator: This is the most common type of elevator and has a request…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