185 questions
1
vote
2
answers
120
views
How do you solve the separation between common and "not so common" functions in your public interface?
class PictureList {
void clear();
void load(json);
void clearAndLoad(json);
void draw();
}
in general clear needs to be called just before load.
Creating just clearAndLoad avoids ...
0
votes
0
answers
88
views
VB.NET Publish Application
This could be a stupid question for most of you who are experts in programming, but I'm not a professional and I've been moving my first steps so it's not so obvious to me.
I developed a VB.NET ...
-4
votes
1
answer
97
views
Public method in public inheritance becomes private in C++
I have a base class with a public method, but when I try to call it from a derived class which inherits publicly from the base class it becomes private. How is it possible? Shouldn't public ...
-2
votes
1
answer
331
views
The Value Assigned to my Number In Public Static Int Method Doesn't Get Assigned [duplicate]
While I transformed parts of my code into methods, an integer I mean to increase under a certain condition (the player score) doesn't. This is a series of methods inside other methods inside a single ...
0
votes
2
answers
551
views
Is there a way to save a chosen color as a public variable?
I am implementing a Color Picker into my app. It works as intended, but i need to save the color as a public variable to use it in the next View.
I have coded the following:
struct Upload: View {
@...
2
votes
1
answer
1k
views
Why can you call a private method on a new instance made inside a method of the same class type, in PHP? [duplicate]
Why can you call a private method on a new instance made inside a public method of the same class type?
class Foo
{
private function thePrivateMethod()
{
echo 'can not be called ...
1
vote
1
answer
1k
views
How to Trigger button click from another form VB Net
I have three forms in total and i want to trigger one of the button on form 3 to be triggered automatically when form 1 loaded
Form 1
Public Class frmIOMain
' In This Form load I want to trigger ...
1
vote
1
answer
504
views
cant delete image from storage laravel
hello everybody im trying to delete an image from local storage with this function but it returns
Call to a member function delete() on string
which is right because when I use dd(destination); this ...
0
votes
2
answers
687
views
Cannot be referenced from a static context
I have the following problem, I am trying to call InterstitialLaunch.java from MainActivity.java to display Interstitial, however, in my case it reports an error from MainActivity.java and says that '...
1
vote
0
answers
69
views
I am trying to make two different time keeping scripts work together
I have been following two different tutorials regarding in-game day night cycles. One is for a TimeTickSystem that enables fires to light up as specific events. The other is for a DayNight cycle that ...
0
votes
2
answers
91
views
Make a String in java Global
I am an Android developer and I have made a string for generating a random 6-digit OTP which is there in the protected void onCreate(Bundle savedInstanceState) {, the first thing in a java program.:
...
3
votes
6
answers
4k
views
Is it possible to write Java code without public static void main(String[] args)?
I am studying for a very basic / beginners Java exam, and when reviewing some example code, I noticed a couple that did not include the method: public static void main(String[] args)
How is this ...
1
vote
1
answer
2k
views
Variable "probably undefined" - am I missing something?
Sanity check. I am still pretty new/dumb when it comes to OOP PHP.
PhpStorm (PS) warns that "$nowGmt" is "probably undefined". Is PS being over fussy or am I missing something ...
1
vote
0
answers
41
views
How do I access a derived classes data members when creating a pointer of the base class to hold the derived class?
I have a class Airplane:
class Airplane {
private:
int value;
public:
// some public functions that arent relevant
};
and then another class that derives from Airplane
class ...
0
votes
1
answer
157
views
PHP is it okay to use (new self) often to access public methods within the static method
By following the OOP approach, I am writing reusable methods into traits rather than creating a plain helper file. So that I can control access in an organized way. For that, I have created various ...
0
votes
0
answers
158
views
calling a public method of the same class twice in another public method
i have two methods in same class method1() and method2(). method 1() is to read a 'String' and extract integers from that string and method2 () is to perform a click operation. This click operation ...
0
votes
1
answer
126
views
What is the difference between inherited methods and public methods?
I have trouble understanding how an inherited method in a subclass from a superclass differs from a public method in a class which can be used in another class.
1
vote
2
answers
686
views
Call a plugins' function in my theme in wordpress does not work
I try to call a (public static) function of a plugin in my functions.php, but that doesn't work.
I tried this code:
include_once( ABSPATH . '/wp-content/plugins/atum-multi-inventory/classes/Models/...
1
vote
1
answer
319
views
Class member function unable to access a private struct node of the same class?
I was working on a homework assignment and I stumbled upon a roadblock
I created a linked list class that looks something like this
List.h
class List{
struct Node{
string data
etc......
0
votes
0
answers
92
views
How can i access class methods and attributes inside a function in class
I have a class which contains a function, so I want to be able to call a class method inside the function
I want to find a way to access the class method send and the attribute file inside the ...
0
votes
3
answers
182
views
ClaiR/Rascal: Best way to list public functions?
I am parsing an C++ header file using ClaiR and want to get a list of the public functions.
visit(ast) {
case \class(_, name(n), _, decs): {
println("class name: <n>");
...
0
votes
1
answer
66
views
Issue calling public function in main
I'm trying to call the public function validInfixCheck() in main but I'm getting this error when trying to compile:
g++ calculatorMain.cpp CalculatorExp.cpp
In function `main':
calculatorMain.cpp:(....
1
vote
0
answers
37
views
Compiler error related to public method granting access to private class member
Given the following class template definitions
template<typename T>
class node{
private:
T& data;
shared_ptr<node<T>>& next;
public:
T& ...
0
votes
1
answer
116
views
Java Class variables are not immutable despite restricting access
I have a matrix object that I have written. I have intended that the matrix is immutable as an attribute of the object, implemented with a mutlidimensional array. as this.matrix. When I call the ...
4
votes
1
answer
278
views
Why is my top-level method public (as opposed to private) on all classes when I declare it in IRB?
I'm currently reading "The Well-Grounded Rubyist", and on page 196 I see the following:
Suppose you define a method at the top level:
def talk
puts "Hello"
end
....
A method that you ...
-4
votes
1
answer
650
views
How do i Declare methods in public and write the code in private [closed]
I have been given this code with the restraints that i can not edit the public in anyway and am not allowed to call any other library's other than the ones specified.
Class example
{
private:
...
-1
votes
1
answer
210
views
How does placing a public method's implementation in a private method prevent disrupting consumers?
This question stems from several related questions, and is somewhat reasking the first which doesn't seem to have a clear answer to the OP's main question:
Private Methods Over Public Methods
Why hide ...
0
votes
0
answers
290
views
Accesssing a private struct defined in class by a friend or a member function
I want to make a public: or friend function to a class return the address of a pointer whose type is defined as a private member of the class.
Example:-
class LinkedList{
struct Node{
int data;
...
0
votes
3
answers
1k
views
Call function from class for many classes without resetting values
so basically I have several different Java classes in Android studio. One of these classes contains a host of functions that I need to call from different classes based on what the user selects. My ...
0
votes
1
answer
588
views
javascript singleton public method "not a function"
I give up. I'm usually a c# developer, but I need javascript for this particular project.
I have a list that I want to be protected with some setters and getters (and also public methods vs private ...
0
votes
1
answer
3k
views
in magento 2 which block methods are available in a template?
m2 is much different than m1.
When I'm writing code (programming public methods) in the template they don't seem to be working. Are all methods allowed like protected and private as well? or getters ...
-1
votes
1
answer
1k
views
Declaring a public class in Java [duplicate]
I have run this code and looked online for solutions. How can I fix this error? I saved PastPresentFuture.java and it still won't run.
YourName.java:7: error: class PastPresentFuture is public, ...
1
vote
1
answer
149
views
How to call a method inside my 'SKScene' from 'ViewController'
I've a method in my SKScene as:
func someTypeMethod() {
print("someTypeMethod...")
}
I tried to call it from my 'ViewController' as:
if let scene = SKScene(fileNamed: "Scene") {
...
-1
votes
1
answer
30
views
Accessing variables from prototype-defined functions
Lets say I have this function, I am trying to get values of value1 and 2 , what’s the right way to do it.
1. how do I make value 1 and value 2 defined , when it exits the function
2. how do i get the ...
6
votes
0
answers
475
views
how do I protect a public API from abuse?
Given a public API which triggers OTP verification to users, is there a way to prevent such an API from abuse/spam?
This API is public and have business reasons so offering on public side.
API is ...
-1
votes
1
answer
35
views
Java:Calling method, initialized in one class, gives Nullpointerexception in other class
I defined a Logininfo class to store the email and password of a user in. I get the email and password from a Login GUI. There are put into the Logininfo class using setMethods. I'm connecting the ...
1
vote
5
answers
1k
views
PHP object functionName():bool
I've one PHP class, in that I found one a function e.g
public static function success(string $userid, string $message):bool
{
return self::add($userid, $message, 'success');
}
Can someone please ...
1
vote
6
answers
1k
views
Why is a template method marked final?
In template method pattern, there is a method marked final, but I cannot understand the meaning of having this method. Please help me out. In another word, in class PackageA, one can implement the ...
0
votes
1
answer
744
views
My main method can't see all public methods in a different package in java
My main method in a package by itself can only see some of the methods in the other package even though they are all public. This is an example of my code.
package stuff.code;
public class ...
-2
votes
2
answers
2k
views
php public function is not working outside of the class [duplicate]
I have created a simple class, variable, and public function. When I try to initiate an object and call the public function from the class outside of the class, I get no output that I can see.
<?...
-3
votes
2
answers
142
views
Using CurrencyInstance in a double instead of a String
Pretty simple question I imagine, just can't seem to figure out the right way to do it.
I have a method that produces my total "cost" (a pre-defined 'double' variable) as a dollar amount here:
...
1
vote
1
answer
4k
views
Angular2 self.parentView.context is not a function
I've got a button element in my *ngFor list item:
<li class="cart__item" *ngFor="let item of cartService.cart$ | async">
<button class="button button--decr" (click)="decrItem()">-</...
0
votes
1
answer
756
views
Public/private moethod declaration-only on ES6 classes with babel
I'm using Babel with default es2015 preset to convert ES6 JS code. Since I'm working in another project with TypeScript, I've come to appreciate the publi/private annotation on methods.
I'd like to ...
-3
votes
1
answer
172
views
My method cannot return a value? [closed]
I wrote a method but method cannot return i value. What can I do ?
public static int contain(String s1,String s2){ //I want wrote a method similar contain
if(s1.length() == s2.length() || s1....
0
votes
1
answer
32
views
Trying to figure out Class and method declaration in Util classes java
I've been having some issues trying to solve this code that my professor sent to me for studying purposes. I usually can solve the isPrime and getPrime no problem but my issue lies with the gcd class. ...
-1
votes
3
answers
3k
views
How to call a Toast in the Class?
The structure of my project is following:
Activity - Fragment - Class
The issue: in Class according to some conditions show a Toast
The problem: I can't call a Context from the class by getActivity()...
0
votes
1
answer
152
views
know the address of Arduino ethernet shield through public ip
Yes, like I wrote the ask title. I want to know it is possible know or see the someway the approximate geolocalization through public ip.
I have an arduino with ethernet shield.
Thanks, I've been ...
0
votes
1
answer
91
views
$.fn.myPlugin vs $.something.myPlugin in regard to private and public methods
So I can't seem to find astraight answer on this, only vague examples of multiple variations where similar plugin/method declarations are used. I know that by saying
$.fn.myPlugin
I am defining a ...
3
votes
1
answer
3k
views
How to verify number of call of private method in public method in Junit?
public void publicMethod() {
for (i=1;i<10;i++)
privateMethod();
}
private privateMethod() {
something...
}
I need to write a JUnit testcase to verify the number of times the ...
0
votes
2
answers
32
views
Confusing example of Private V.S. Public method in book <Javascript Patterns>?
I've been reading Javascript Patterns by Stefanov recently. And I found this example confusing to me here:
Another case of using a convention to mimic functionality is the private members >con- ...