I’m making a method called fillList. The method will require an arrayList in order to work and the output will be void. What the method is supposed to do is to fill the gaps between the numbers of the List. Example: Input: Output: The code I have so far is this: My idea was to add 1 to the value
Tag: methods
How to fill an array with a new row in Java?
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 *
How do you have a class change the value of an attribute of another class?
Let’s say I have a class named Door with an attribute that states whether it’s open or closed. Then, there is another class named Person, that is assigned to that door. How would you tell the person to open/close the door by changing the value of the attribute in the Door class with a method in the Person class? Answer
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().
Using attributes of one class in another class
I am trying to move the assertThat method from Authentication class to the BDDStyledMethod class but the current code will generate the following error “‘Creds(java.lang.String)’ in ‘steps.Authentication’ cannot be applied to ‘()'” How do i correct my code so that the assertThat method works in the BDDStyledMethod class ? Answer The problem is with the Creds method. It is not