methods

expression does not produce a value when calling a sub

有些话、适合烂在心里 提交于 2019-12-14 04:12:16
问题 i want to call this public sub hungrys(gutom as string) from my zooanimal class to my form1.vb. for reference, please refer to my code. i always get an error "expression does not produce a value" in my Textbox10.text = za.hungrys(gutom as string) Public Class ZooAnimal Public Sub New() hungry = isHungry() Public Function isHungry() As Boolean If age > 0 Then hungry = True End If If age <= 0 Then hungry = False End If Return hungry End Function Public Sub hungrys(ByRef gutom As String) If

“the method ** is undefined for the type string” in Eclipse

爷,独闯天下 提交于 2019-12-14 04:09:51
问题 I am currently completing a project and am trying to create a menu. The menu itself works alright but when I try and link to the other java file that the method itself is in I get the error "the method method name is undefined for the type String". Below is the code that I am using to try and link to the method in the other java file. { if (menuChoice.equals("A")) { System.out.print("Enter the Movie ID: "); movieID = sc.nextLine(); movieID.borrowMovie(); } if (menuChoice.equals("a")) { System

Python Magic Method Augmented Assignment misunderstanding

纵饮孤独 提交于 2019-12-14 04:08:48
问题 I'm creating a simple angle object which is, in it's simplest forms, an integer value that recurs when it goes above 360 (back to 0) or below 0 (back to 360). I implemented the magic methods for augmented assignment and for some reason this isn't working. class Angle: def __init__(self, angle): self.angle = angle def __add__(self, other): """Check for recursion, then return the added value.""" val = self.angle + other while val > 360: val -= 360 while val < 0: val += 360 return val def __radd

How to return an two dimensional array index from a method?

无人久伴 提交于 2019-12-14 03:58:01
问题 Im creating a tic tac toe program from here: http://programmingbydoing.com/a/tic-tac-toe.html I'm having trouble finding out how to return an array index from a method. I want to user to input 2 integers, ( row, column) and have that index returned and have either char 'O', or 'X' replace the blank corresponding index. I'm a bit new to java, and am trying to learn it as fast and efficiently as possible to catch up in my class. import java.util.Scanner; public class ticTacToe{ public static

How should I use the alias_method_chain for the build method?

末鹿安然 提交于 2019-12-14 03:56:56
问题 I am using Ruby on Rails 3.2.13 and I would like to properly use the alias_method_chain :build, :option_name statement since I am getting a strange error. That is, ... ... in my controller file I have: class Articles::CommentsController < ApplicationController def create @articles_comment = @article.comments.build(params[:comment]) ... end end ... in my model file I have: class Articles::Comment < ActiveRecord::Base def self.build_with_option_name ... end alias_method_chain :build, :option

Java: do methods inherit a JRE super class, like classes inherit Object?

ぃ、小莉子 提交于 2019-12-14 03:55:56
问题 As far as I know, everything is an object in Java. I am looking through the java JDK and am experimenting with creating a custom JDK that allows me to perform more debugging operations. For example, I can manipulate every object by changing the Object.java class. My question is: do methods inherit a class from the JRE as well, so that I can modify this parent to eg. make a method save it's most recently passed arguments? Thanks. 回答1: If you only want to enhance debugging, you can start with

In PHP, are objects methods code duplicated or shared between instances?

爱⌒轻易说出口 提交于 2019-12-14 03:55:18
问题 In PHP, if you make an array of objects, are the object methods (not data members) copied for each instance of the object in the array, or only once? I would assume that for memory reasons, the latter is true; I just wanted to confirm with the StackOverflow community that this is true. For example, suppose I have a class MyClass with a couple of methods, i.e. class MyClass { public $data1; private $data2; public function MyClass($d1, $d2) { $this->data1=$d1; $this->data2=$d2; } public

In Java compiler,The print in System.out.print can be defined as identifier or Keyword? [duplicate]

蹲街弑〆低调 提交于 2019-12-14 03:32:44
问题 This question already has answers here : In Java compiler,which type can be defined as identifier ( ID ) or Keyword (reserved word)? (2 answers) Closed 4 years ago . I have studied about java which have listed 50 Java keywords. There is a homework of Lex, the goal is to recognize the word is keywords, IDs, symbols, operators. But there is one more little problem is the code below, is print in System.out.print() an ID or keyword? public class HelloWorld { public static int add(int a, int b) {

Which is the best Method used for Sorting? [duplicate]

梦想的初衷 提交于 2019-12-14 03:29:21
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: What sort algorithm provides the best worst-case performance? Which is the best method that can be used to sort an Integer array?Is Quick Sort efficient? Some of the common methods used for sorting are mentioned in [spam link removed] 回答1: They are different sorting methods are available with different features. Bubble Sort [It's simple but not good for large data][1] Selection Sort [Selection sort is noted for

Call a method every x minutes

我只是一个虾纸丫 提交于 2019-12-14 03:12:34
问题 currently I have a application which can send notifications, I would like this application to be able to send these notifications automatically every x minutes (for example, 15 minutes is the default). The app may or may not be currently running when this notification should be sent. After some reading, I've determined that an AlarmManager would be used here, but I cannot figure out how to call a method from it. I already have the notification code, I just need a way to call it every x