Explanation of Solution
Given: The better-ticket-machine project.
To find:Â The steps to use the debugger in the method named insertMoney present in the class TicketMachine and apply test conditions that executes if-statement as well as else-statement.
Solution:
In order to set the breakpoint in the first line of insertMoney method, it is necessary to open the editor of class TicketMachine.
An editor window will appear on screen.
Now, create an object of TicketMachine class and set the cost to 500.
Now, invoke the method named insertMoney and enter the amount as 1000.
When the user clicks ok button, a new debugger window will pop-out on the screen.
Now, click the Step command in the debugger window.
The line of execution has now been changed from the first line to the second line. It has now been entered inside the if-statement.
Again, click the Step command in the debugger window. The value of the variable named balance present in the section of instance variables has now been changed from 0 to 1000 and the line of execution has now been moved to the last line of the insertMoney method...
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Write a method that takes two string parameters, and tells whether the first is a substring of the second. You can't use framework methods that do this for you, such as indexOf(). In other words, you have to write the loops yourself. But, you can use the primitive methods such as charAt(). Also analyze the program's performance and state the big-O complexity of your method. Provide a screenshot of the code working.arrow_forwardCopy your previous class definition for RectangularSolid from the previous problem, including both methods. Provide mutators (setters) and accessors (getters) for each of the three parameters. Use the naming convention for these methods that is demonstrated in your textbook (i.e. do not use the property function or decorators). These methods should allow a program using your code to modify the parameter values after creation and to read individual parameter values.arrow_forwardOpen the clock-display project and create a ClockDisplay object by selecting the following constructor: new ClockDisplay() Call its getTime method to find out the initial time the clock has been set to. Can you work out why it starts at that particular time?arrow_forward
- can you please help me with the last part of this code because I don't understand this; part of the code is below and the other part of the code is in the photo. question: In the LightsOutPuzzle class, write a method copy(self) that returns a new LightsOutPuzzle object initialized with a deep copy of the current board. Changes made to the original puzzle should not be reflected in the copy, and vice versa. >>> p = create_puzzle(3, 3)>>> p2 = p.copy()>>> p.get_board() == p2.get_board()True >>> p = create_puzzle(3, 3)>>> p2 = p.copy()>>> p.perform_move(1, 1)>>> p.get_board() == p2.get_board()False In the LightsOutPuzzle class, write a method successors(self) that yields all successors of the puzzle as (move, new-puzzle) tuples, where moves themselves are (row, column) tuples. The second element of each successor should be a new LightsOutPuzzle object whose board is the result of applying the corresponding move to the current…arrow_forwardMy code won't print out the desired test cases. For instance, the time and the event did not properly store it in the skiplistmap class, so it prints out none regardless of time and event. Also, when printing out the skiplist, it will just print out empty for each level regardless of the time and event being stored. So, can you take a look at my code and fix it? Also, how do I use a FakeRandheight class for put(k, v)? mport java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;public class HW5 {public static void main(String[] args) throws FileNotFoundException {SkipListMap<Integer, String> slm = new SkipListMap<>();SkipListMap<Integer, String> cancelEvents = new SkipListMap<>();File input = new File(args[0]);Scanner in = new Scanner(input);while (in.hasNextLine()) {String line = in.nextLine();String[] parts = line.split(" ");if (parts.length == 0) {continue;}String check = parts[0];if (check.equals("AddEvent")) {if (parts.length < 3)…arrow_forwardNeed help with this question. Must be answered using any ADT's from the class. Can use reverse polish notation. Make sure it is in java. All the info is in the image.arrow_forward
- Implement following three methods that passes sturctural tests: getXStep and getYStep: helper methods, they indicate how far (-1, 0, or 1) have to be taken to take x and y coordinates. moveAndSet: it moves the piece and changes the value of the new position. Use the above helper methods in the code of the method. If the move would make the figure leave the board, cancel the move: the figure remains where it was, the state of the board doesn’t change at all, and the method immediately returns 0. Otherwise, the method returns the old value of the new position, and its value is set to the second argument. Különben a metódus térjen vissza az új mező régi értékével, és a mező értéke álljon át a paraméterben megadottra. setAndMove: it is similar to moveAndSet but it changes the value of the position before changing position @Test @DisabledIf(notApplicable) publicvoidmethodGetX() { it.hasMethod("getXStep", withParams("direction: walking.game.util.Direction")) .thatIs(FULLY_IMPLEMENTED,…arrow_forwardPlease check images for the rest of the question and provide code with comments and explanations. Thank you. Write a set of static methods, to make console input simpler. Consider that the only console input method using the Scanner class is inputString(), shown below; include it in your solution. This means you are not permitted to use the Scanner class in any of your methods. public static String inputString (){Scanner scan = new Scanner (System.in); // attach to consolereturn ( scan.next() ); // return next string from input console stream}Example of calling and testing this method in your main():String str = inputString(); // get input from console, assign to strdisplayln ("Input A is: " + str); // display input stringdisplayln ("Input B is: " + inputString() ); // get input and displayarrow_forwardWrite and test directed testcases for the testbench. Use ModelSim or a similarsimulator to test the transactor. Hand in a copy of the code and evidence of its function.arrow_forward
- Implement 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_forwardWhat is encapsulation?Clarify with help of example?arrow_forwardWhat kind of statement is this?If it is a dog (d), it has fleas (f).arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT