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.

0 votes
0 answers
9 views

Menu driven program methods continue without waiting for user input

package sample; import java.util.Scanner; public class Sample{ public static Scanner inp=new Scanner(System.in); public static String name,degree; public static int index; public ...
user avatar
0 votes
1 answer
27 views

Calling Partial Method C#

I have question about c# partial method. How to use(call from main) partial methods if they are private by default? using System; namespace SecondProject { internal class Program { ...
user avatar
1 vote
1 answer
24 views

How do you calculate the average of JSON values and iterate this x amount of times with Javascript?

I have a JSON data set which looks like this: { name: "Evelyn", assignment: "SCRUM", difficulty: 3, fun: 4 } Etc. I am trying to calculate the average of the ...
user avatar
  • 13
-4 votes
0 answers
15 views

Using def before __init__ method in python [duplicate]

Why we use def before __init__ method in python? __init__ method is already a method then what is the purpose of using def before __init__ method? What does __init__ exactly do in python? Does it act ...
user avatar
0 votes
2 answers
28 views

Size of the loop is printing less numbers than i want to be in my Set JAVA

Basically i want to generate random numbers between 1-10, which are put into my set. The thing is that my loop size is from 0 to 9 and it generates random numbers but, once it's 5 numbers, once 7 ...
user avatar
0 votes
2 answers
35 views

How to pass click button event to trigger another function in WPF main window?

I am new to C#/WPF with very little expertise and finding difficulty with this task. I have a button : private void scan_click(object sender,RoutedEventArgs e) {} I have the main window in WPF ...
user avatar
  • 1
0 votes
0 answers
18 views

do instances point to their own classes (to access methods)?

How can the compiler know what method is an object calling? lets say for example: class Person { string name; int age; void walk() { // do something with name and age } ...
user avatar
0 votes
0 answers
29 views

The scanner in my program is asking the user for second input, why is the scanner doing so?

I do not understand the reason why the method below is asking me for a second input when i type an integer as an input. Note, as far as i know, the method works fine when the input is a non integer, ...
user avatar
0 votes
1 answer
13 views

How to create ActionFilter in Javascript?

I understand that there is a concept of Action Filters in languages like C# using ASP.NET. I would like to have this kind of pre-processing functionality in my class methods, using Javascript. Is this ...
user avatar
0 votes
1 answer
51 views

What does this Method return? (C#)

Not so long ago I moved from Java to C# and I'm still learning and today I bumped into this in some code. public async Task<(decimal Price, string NativeCurrency)> GetCurrentStockPrice(string ...
user avatar
  • 291
2 votes
2 answers
59 views

Java method that produces an object

I have to follow the below UML diagram to design a programme. The programme is supposed to generate 2 random integers, and ask user for input the answer to the sum of said integers. However, I am not ...
user avatar
1 vote
4 answers
46 views

Signature of interface's method includes a class, which implements the interface itself

Considering the rules of good OOP and design, is it correct to write a method in an interface which has as input types or output types classes which implements the interface? I give you an example of ...
user avatar
-2 votes
4 answers
41 views

Power a number with input() and function within class

I'm able to calculate area of square without using class/method but when I want to add it to the class if it is failing on line 8 with the following error: area() takes 1 positional argument but 2 ...
user avatar
  • 942
0 votes
1 answer
30 views

Class attribute with value and callable methods

I want to create a class with an attribute which can be called itself and return a value, and which can also call its own methods. The usage I want is like this: f = CSVFile() f.valid_transactions # ...
user avatar
  • 667
0 votes
0 answers
29 views

Create a function to flip every n characters in a string. Output should have no commas in it, but my output does

var input = 'a short example'; var output = flipEveryNChars(input, 5); The result should be ohs axe trelpma, but my result is o,h,s, ,ax,e, ,t,re,l,p,m,a. Why are there still commas after using ....
user avatar
  • 1

15 30 50 per page
1
2 3 4 5
1962