Concept explainers
What happens if you try to compile the TIcketMachine class with the following version of refundBalance?
What do you know about return statements that helps to explain why this version does not compile?
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Additional Engineering Textbook Solutions
SURVEY OF OPERATING SYSTEMS
Java: An Introduction to Problem Solving and Programming (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Management Information Systems: Managing The Digital Firm (16th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- Hi, I am making a elevator simulation and I need help in making the passenger classes using polymorphism, I am not sure what to implement in the comment that says logic. Any help is 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. This is what i have so far public abstract class Passenger { protected String type; protected int…arrow_forwardHelp, I making a elevator simulator, I need help in writing code in the Elevator class and it's polymorphism class. I am not sure what to do next. Any help is 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_forwardcheck the Coin class and cointester program below. Write a new method .flipCoins(), that flips two (2) coins: the current coin and the coin passed as a parameter. The method returns the integer addition of the flipSides of both coins. Example, as if used in the CointTester program class:Coin bobCoin = new Coin(); // create Coin object [using Coin() constructor]Coin aliceCoin = new Coin(6); // create Coin object with 6 sidesint combinedFlip = 0; // combined flip value of two coinscombinedFlip = bobCoin.flipCoins(aliceCoin); // flip both coins, returned combinedSystem.out.println ("Flip of two coins: " + combinedFlip); Coin class: import java.util.Random; blic class Coin{private int numSides = 2; private int flipSide = 0;private static int coinCounter = 0; private int uniqueID; /** default constructor for Coin class*/public Coin (){coinCounter++;uniqueID = coinCounter; }/** constructor that sets the sides for Coin class* @param numSides the number of sides of the coin*/public Coin…arrow_forward
- Iterating over a collection of items is the job of the for construct's looping mechanism. So long as there are things to process, it will keep running forever. So, what do you make of this?arrow_forwardWrite 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_forwardImplement a complete calculator system in JAVA and GUI. implement add, sub, multiply, divide in your system. You have to add overloaded method for float and integer arithmetic. (assignment 3 question 1) calculator should also calculate square, power, square root functions as well. you must implement the GUI and styling in calculator. (10)arrow_forward
- In order to implement different ways of discount strategies for an object oriented parking system, we have a DiscountStrategy interface and CompactWeekendDiscounts class. The CompactWeekendDiscounts class class checks if the date is a weekend and the car we are about to park is compact and makes a discount. Based on the class diagram implement the two - a DiscountStrategy interface and CompactWeekendDiscounts class using java. (no need to implement ParkingLot class )arrow_forwardcan someone help me? The questions are: 1. Add an addExerciseAdd method that adds an exercise to a private variable exercises in Exercise You don't need to create a getter or setter for this private variable. 2. Modify the constructors in Exercise so that you can create two types of workouts (let one constructor use the other; each variable can only have a value in one constructor): a training schedule with exercises, but without a trainer. a training schedule with exercises and with a trainer. import java.util.ArrayList;class Exerciseplan {private String customer;private String trainer;Exerciseplan(String customer) {this.customer = customer;}Exerciseplan(String customer, String trainer) {this.customer = customer;this.trainer = trainer;}private void printExercise(String name, String muscleGroup, Integer numberOfSets, Integer repetition, Integer restTime) {System.out.println("Oefening voor " + muscleGroup + ":" +" herhaal " + numberOfSets + " keer " +"(rust tussendoor " + restTime +…arrow_forwardThe Cat and Dog class below implement the Animal interface. All animals have names, but only dogs do tricks. Implement the describe method, using the instanceof operator to test whether the given animal is a dog. If so, return the name, a space, and the trick that the dog can do, such as "Helmut barks at the moon". If it is any other kind of animal, return the name, a space, and "has no tricks". public class Animals{ /** Describes the given animal. @param pet an animal @return a string with the animal's name, a space, and either the trick that the animal knows (if it is a dog) or a string "has no tricks" */ public static String describe(Animal pet) { // TODO: Complete this method } // This method is used to check your work public static String check(String name, String trick) { Animal pet; if (trick == null) pet = new Cat(name); else pet = new Dog(name, trick); return describe(pet); }arrow_forward
- https://youtu.be/4hAoK54Pfdc Here is a video regarding the kit component.arrow_forwardShare at least three tasks that you know WinMain (starting) method handles.arrow_forwardHelp, I am making a elevator simulation using polymorphism. I am not sure to do now. Any help would be appreciated. My code is at the bottom, that's all I could think off. 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. public abstract class Passenger { public static int passangerCounter = 0; private String passengerID; protected…arrow_forward
- 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