So what I have so far is a randomized board containing numbers 1, 2 and 3. The board is 6 * 10. (So 6 Columns and 10 rows). The plan is when the user gives an input, a new row of randomized numbers should be added to the board. The thing is that the 2D array will be 6 *
Tag: methods
How can I count the amount of extra numbers are given over a base value?
There is a base price and its only applicable when hrs = 50 and ppl = 30. I need to make it so that for each extra hrs or ppl it will charge an additional rate on top of the base rate. I am not sure how to make a piece of code that counts the extra hrs and ppl.
Method to output object details taken from main class
i have a created a main Pet class which contains the pet name and age and 2 sub classes for a Cat and dog which contain the breed, i am trying to create a method to display the information as a string but i am not sure how to pass the arguments to the method. When trying to use the
Is there a way to ovveride a method without extending the parent class?
I have a player class which extends a JLabel and I wanna override an Update method from a parent class to implement physics for the player but I have to extend the parent class which I cant do cause I already extended the JLabel, any help will be appreciated. Answer The short answer is probably no. You can/have to override
How To Use Response value In Another Method
I am working on restassured and here is my 2 methods. I want to use the albumId returned from the AlbumList method in the other method I know these are void and doesnt return anything but idk how to use it. Bye the these methods are in the same class. Thanks in advance } Answer The easiest way is to
Trying to stop a Do-While Loop for an application
I’m creating an application for a homework, the problem is that I am trying to create a do-while loop to exit the application (Using the question “Do you want to exit (Y/N)”). To work with the do-while loop, I created a method to store the app and then called the method in the do-while loop, so that when I try
Calling an abstract method from an interface without overriding it
I am working on a Java project and want to understand the source code before implementing mine into it. The problem im facing is, how can the source code uses the abstract method from an interface without actually overriding it? At first, I came to this statement: DeviceService deviceService = context.deviceService(); It is using ‘context’ to call the method deviceService().
Calling a Method in a running Thread Object [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 months ago. Improve this question I’m a Java beginner. I want to call a Method in a running Java Thread Object. It always throws this
How to use generics for type safety while using `removeRange` method of ArrayList
Since the method – removeRange(int startIndex, int ) is protected, we need to use it in a class extending ArrayList. Below is my code – Output – Now to use type safety I need to write – MyClass<String> extends ArrayList<String> but doing so gives error in main method of String[] – MyClass.This cannot be referenced from a static context So
Returning a value from one method to another to be used in the output
I can’t figure out how to return the value of finalCost to the main method and have it printed. Specifically, I can’t find how to use the returned value in the “println” line. Answer You call calcMonthlyCharge(downloadLimit),but don’t store the returnvalue. When you call System.out.println(“Plan monthly cost: ” + calcMonthlyCharge(finalCost) ); It is unknown what finalcost is, this is a