Questions tagged [methods]

A method is a block of code that performs a task and is associated with a class or an object. It is related to the non-object-oriented concepts of functions and procedures.

Filter by
Sorted by
Tagged with
-4 votes
0 answers
37 views

How to write a function inside a class in python?

There is a class in python and we can write our program inside a class with any name defined to the class. So normally when we make a function using "def" then how we can make a function ...
Quaise Mallick's user avatar
0 votes
2 answers
49 views

Automatic horizontal scrollable div

const scrollableDiv = document.querySelectorAll(".scrollableDiv a"); const contentH2 = document.querySelectorAll("#content h2"); contentH2.forEach((element, index) => { ...
Marius123's user avatar
-1 votes
0 answers
14 views

git command is not working any value in makefile

git command is not returning value i am expecting the answer. However when I run make get_log nothing is returned, Although if I run git log directly in the CMD I get results. UPDATE: the file is ...
Shrujan Meda's user avatar
-1 votes
0 answers
11 views

Is there a way to implement methods in MyLinkedList Class and if so how do I implement them?

I'm trying to implement methods for Chapter 24 Programming Project called Exercise24_01 and I'm trying to make it work. The code below is the code I have so far: import java.util.*; public class ...
RWorker's user avatar
0 votes
1 answer
24 views

Issue with Inheritance in Python - Unable to Access Parent Class Method

I'm currently working on a Python project where I'm using inheritance to create a base class and a derived class. However, I'm encountering an issue when trying to access a method from the parent ...
Divyansh Singh's user avatar
0 votes
0 answers
13 views

understanding selenium chaining call

I am confused about the implicit call which is chain call: WebDriver driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); driver.manager(); return a ...
user3559982's user avatar
-4 votes
0 answers
30 views

Reversing a string in Python and use class and method approach onlyy [duplicate]

Write only the function reverseWord() that takes s as parameter and returns the reversed string. Tried solving the problem using class and method approach, but then got a runtime error. I want it to ...
Neelansh Singh's user avatar
0 votes
0 answers
63 views

Double Methods both returning 0.0 [closed]

This is for my Java class and for the life of me, I can't seem to figure out why my double methods near the bottom are giving me back 0.0 for my output. I'm still pretty new to java and this has to do ...
Buddah's user avatar
  • 1
0 votes
0 answers
33 views

The object.assign() parameters

lady/gentleman, gm/gn, I need your help: const userDetails = { firstName: "Jane", lastName: "Daniels", userName: "jane.daniels", email: "[email protected]", comapny: "...
Angus's user avatar
  • 55
0 votes
1 answer
33 views

Want to Call a method from the Main twice and display the two outputs

Im wanting to call a method twice where the user has to input two positive doubles. I then want those to be returned to the main() and displayed. I'm unsure how to call the method from the main as I ...
Don Boss's user avatar
0 votes
1 answer
42 views

How to remove an item from list without using the remove() method?

I want to remove the last item from the list but it's not allowed to use methods. Any ideas? <I don't want to rewrite my whole code so here we are... xd> Keres.Remove(Keres[Keres.Count - 1]); ...
Zsooo's user avatar
  • 37
-3 votes
1 answer
33 views

Why I Can't Use My Method in Another Class? (The Method X is Undefined for the Type Y)

I wrote a code in Java but I'm keep getting an error named "The method getMinor(Matrix) is undefined for the type Main." for the last line of Main class. I can use my other methods in Main ...
refik's user avatar
  • 23
-5 votes
0 answers
39 views

Writting simple c class [closed]

I have used typed pionter on methods (ime this in c++ methods), then redirected its instance to a correct class definitivno by using macro (#define c(x) (*(x-> = x)) ) witch is im the file class.h. ...
Franjo's user avatar
  • 1
-1 votes
0 answers
32 views

How do I fix "incompatible types :possible lossy conversion from double to int"? [duplicate]

I'm currently learning Java and I've been assigned a program that would create arrays with 4 methods to convert Celcius to Fahrenheit and vice versa so it would have to use the main, controller, ctof ...
Andrev Siaulys's user avatar
0 votes
0 answers
52 views

Moving the method to another class make it stop working

I have this class called Screen package main; import java.awt.Dimension; import java.io.IOException; import javax.swing.JFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; import ...
TokenZ's user avatar
  • 1
0 votes
2 answers
31 views

How to catch exception from every method of a class in Python?

I am writing code which utilizes a third-party library which I do not have access to modify. To interface with the library I have written a protocol "Stub" class as follows to allow code ...
opnightfall1771's user avatar
0 votes
1 answer
34 views

String format doesn’t show int number 1

I have this method that receives seconds (as an integer) and returns a string with the years, days, hours, minutes and seconds. When any of the values (years, days, hours, minutes or seconds) = 1 it's ...
Darian Hiebl's user avatar
1 vote
2 answers
41 views

Using a method to create objects

I have a question regarding creating object using a method, please see my code below: import java.util.ArrayList; import java.util.Scanner; public class Student { private String name; private ...
Jack M's user avatar
  • 61
-1 votes
0 answers
25 views

How can i fix NullPointerException when calling a method runned by service?

I have an application to calculate prayer times. The final Fajr prayer time is set using the getFajrFinalTime() method in PrayersTimes.java. The current time is calculated and equated with the final ...
The Artist For Informatics's user avatar
0 votes
1 answer
100 views

c++ returning const reverse iterator from a class method, but method cannot be const?

I am trying to return a const reverse iterator from a class method. But my code doesn't compile when I mark my method as const. Without const the code compiles with no troubles. Any idea why? #include ...
Miroslav Krajcir's user avatar
0 votes
0 answers
40 views

Why is the paintComponent() method executed without being called?

i am just learning Java , today i ran into a problem while practicing. first, I inherited from JPanel and drew a diagonal line using the paintComponent method. but in the main class of the program, I ...
amir's user avatar
  • 11
0 votes
1 answer
18 views

using minusMinutes() in the LocalTime class in the time package

I am quite new and am asking to see how to use this method. here is my problematic code... import java.time.LocalTime; class Workingtime{ public static void main(String[] args){ LocalTime ...
working.monkey's user avatar
0 votes
0 answers
43 views

what is the best way to implement constructor with many arguments in PHP? [closed]

I have the following class <?php class ClassA { private string $name; private string $url; // more props public function __construct(string $name = null, string $url = null) // ...
Steve Silva's user avatar
0 votes
0 answers
47 views

Use this keyword in static method of class

export default class SpecialtyAPI { public static async getSpecialtyList(request: Request, response: Response): Promise<TResponseData> { public static async getSpecialtyData(request: ...
user21696941's user avatar
0 votes
0 answers
24 views

What do you call a method parameter in Java that takes values from a objects attribute? [duplicate]

What do you call Java methods that take values from actual object or class attributes? If the very bottom method takes what is called a "Formal-Parameter", then what do you call one that ...
smouvfox805's user avatar
0 votes
1 answer
74 views

How object-to-object communication in Java works?

I am new in learning Java just finished with Methods lecture. I am working on assignment and I need to write program for Money transfer service. I have two classes, first one is CurrencyConverter and ...
Kekicbj's user avatar
0 votes
0 answers
19 views

I'm unsure of how I should be calling my methods to draw my snake with StdDraw

I'm using StdDraw to create a snake program. When I run my program it jumps to the game over display without actually entering the game. I'm sure there are quite a few things I have to fix, but please ...
Christian's user avatar
0 votes
1 answer
31 views

How to hint custom types for method parameters, where both the type and method is in the same class?

How do I hint that the symbol parameter in the function add_symbol, is a type of Lexer.symbol? It says that it's not defined. I tried a few things and I don't know what will work. class Lexer: ...
devian's user avatar
  • 15
4 votes
1 answer
85 views

Go: How to specify a type constraint in which a method's argument type is the same as that of the receiver

I would like to specify a type constraint like the following: type Comparer interface { Compare(another Comparer) int } But I want the implementing type to pass in the concrete type of itself ...
Rich's user avatar
  • 1,741
0 votes
1 answer
57 views

How to call a method from a subclass?

So I have this project where a I have a certain question, and if we answer it correctly is gives a certain amount of points that varies depending on the theme of the question. I have a class named ...
Comicas's user avatar
0 votes
0 answers
28 views

Error with parsnip fit when I have added a class to a model specification

I have built a function that makes a model spec. I wanted to try my hand at adding a class to the object so I could build generic workflow and fitting etc functions. Here is the function: ...
MCP_infiltrator's user avatar
0 votes
3 answers
103 views

Why are the class and method names the same? [duplicate]

I have just started learning Java. today, during training, I saw some code that had the same method and class name. I wanted to know how such a thing is possible? does the (public Animal) part work as ...
amir's user avatar
  • 11
0 votes
1 answer
20 views

IntelliJ Context Suggestions for Missing Method

When using IntelliJ and referencing a non-existent method, normally I would expect the context to suggest "Create Method" and try to use the apparent signature. This used to work in the past,...
Bradley M. Small's user avatar
-2 votes
3 answers
77 views

How do I access my private variables from my static method

I have two private instance variables xCord and yCord. I have a public static method called getSlope that takes in two arguments of class Point. When I try to use .yCord or .xCord on them it says non-...
Ray Coia's user avatar
1 vote
4 answers
53 views

How to process a column (class - string) using the method rjust in Python?

The main problem is, I can't process the column using the specified method rjust(), while I can perfectly apply it in ordinary strings Sample Input: 8 11 123 Sample Output (what I expect): 008 011 ...
Eugene Morrison's user avatar
0 votes
0 answers
64 views

fill() method doesn't work. Playwright/Python

I'm writing automated tests using Playwright in PyCharm. I have a method: python def fill_email_input(self, email="email_value"): email_input = self.page.locator(SignInPageLocators....
Semen's user avatar
  • 1
0 votes
1 answer
123 views

insert method of the simple prefix tree

I am asked to implement the insert method of the simple prefix tree which is defined as below: def insert(self, value: Any, weight: float, prefix: list) -> None: """Insert ...
LianNuo 's user avatar
-1 votes
0 answers
26 views

implement an interface from inside a block [duplicate]

I want to implement an interface from inside a block. I tried this: package io type reader interface { read() bool } func new_reader() reader { type hello struct{} return hello{} } result: ...
user22859957's user avatar
0 votes
1 answer
30 views

Error: list index out of range - CustomTkinter App

I am very new with python, I've been now creating my own project as I believe is the only way to learn faster. I am working in a project that should use 5 formulas to calculate an output. To do that I ...
Jose Ricardi's user avatar
-3 votes
2 answers
80 views

Confusing return statment [closed]

Trying to pass x from method to another, then sum it before printing it in main. The program works perfectly, but 8th line is confusing me. I need a brief breakdown of this code, which I obtained ...
Noob's user avatar
  • 3
0 votes
0 answers
19 views

export a javascript instance of a class to another file and retain prototype and methods

I am working on becoming better at javascript, node, and express and am trying to serve up an instance of a class from an app.js file to another js file and still be able to retain and implement the ...
theRook's user avatar
-3 votes
1 answer
58 views

Write a method that returns the sum of numbers divisible by a divisor in a given range (range includes from / to) [duplicate]

public static int sumDivisible(int from, int to, int divisor){} Example: divisor: 2, from: 2, to: 6 Result: 12 (2+4+6) I can't understand how to build it. Someone please explain. public class Main {...
Matvei Johns's user avatar
-3 votes
1 answer
53 views

How to pass value in java from methods to methods [closed]

I am new to java, I want to confirm on how to pass the values from methods to another methods/class. eg. in package1 public class class1 public void method1() { a + a = e } in package1 but in ...
Jimmy's user avatar
  • 373
-3 votes
1 answer
42 views

Supported methods: PATCH, DELETE [closed]

I am new to Laravel and I am trying to update an item quantity in a cart, so I set this route: Route::patch('/item/{rowId}', [CartController::class, 'update'])->name('item.update'); and my form ...
MOHAMED KESSOUM's user avatar
0 votes
0 answers
16 views

Simulation of flow around a cylinder in OpenFOAM

Geometry I have a made a geometry to simulate the flow around a cylinder using FreeCAD and exported it as .stl file. I am confused how to proceed next? I am using pitzDaily case directory for this ...
Martin Mathew's user avatar
-2 votes
1 answer
22 views

About flutter list

Can anybody please explain to me what operation does list.from() method performs. As I am a beginner I couldn't understand it. I just wanna know about the list.from() method Iterable l = json.decode(...
Suman Sen's user avatar
-1 votes
0 answers
30 views

Difference between private and public properties inside a private method

I'm encountered this question in a job interview: In Dart, what is the difference between a private variable and a public variable within the scope of a closed function/method? I didn't know the ...
fabio carvalho's user avatar
0 votes
0 answers
48 views

The Humanoid does not move

So I have this dummy on Roblox Studio welded to a P90 model (a gun). I need this dummy to move, but when I call :MoveTo to the humanoid of this dummy it just does not move Any help is appreciated, ...
Paysmon's user avatar
0 votes
1 answer
44 views

How to run a method every time an object is accessed (or copied from/to) in a list?

I am try to learn about stacks while using the turtle class in Python. Basically, I write a script to draw a triangle using turtle. To do this, I made a Shape class with size and turtle as the ...
Bark Jr. Jr.'s user avatar
-1 votes
2 answers
88 views

Using Java to reduce BigIntegers using recursion. The method reduces the number completely, then loops to the number 'upwards' for unknown reasons

My assignment is write a method that reduces a BigInteger using recursion. If the number is even, split it in half then repeat the process, if the number is odd, then multiply it by 3, add 1, and ...
Jesse Lucas's user avatar

1
2 3 4 5
608