methods

NoMethodError in Orders#new

别来无恙 提交于 2019-12-11 20:27:38
问题 I'm receiving an error when it comes to entering data into my table. undefined method `price' for # I was able to add the Price into my Order table, but when it comes to adding new data. I receive a, NoMethodError in Orders#new. I went into my text editor and deleted the highlighted piece of code, but the field to enter a price disappears all that is left is the title, Price. Showing /Users/nncyvallejo90/Documents/springproject/app/views/orders/_form.html.erb where line #20 raised: undefined

Can fields of the class and arguments of the method interfere?

别等时光非礼了梦想. 提交于 2019-12-11 20:11:14
问题 I have a class with a fields called "a". In the class I have a method and in the list of arguments of this method I also have "a". So, which "a" I will see inside of the method? Will it be the field or it will be the argument of the method? public class myClass { private String a; // Method which sets the value of the field "a". public void setA(String a) { a = a; } } By the way, there is a similar situation. A method has some local (for method) variables whose names coincide with the names

Changing a variable outside the scope of a method in Java

懵懂的女人 提交于 2019-12-11 19:59:39
问题 So I'm trying to change the value of a minimum and maximum guess (with the actual guess being made by a random number generator) in order to stop the program from guessing the same number twice. I have a method that makes a guess but also tries to set a lowest and highest guess which then changes when the method is used again public static int takestab (int low, int high) { int estimate; estimate = (low + (int)(Math.random() * ((high - low) + low))); if (estimate < number) { lowestguess =

Where are comparisons in java sorting methods?

喜欢而已 提交于 2019-12-11 19:56:35
问题 Question: Where are comparisons being made in each separate sorting method? Also if you know please tell me which method count numbers are wrong and where to place my counters instead.trying to understand where and how many times sorting methods make comparisons. Method A B Selection 4950 4950 Bubble 99 9900 Insertion 99 5049 Merge 712 1028 Shell 413 649 Quick 543 1041 Okay so to explain some parts, basically Array A is an array from 1-100 in ascending order. So this should be the minimum

Android - Could not find a method playaudio(View) in the activity class android.app.application

纵然是瞬间 提交于 2019-12-11 19:45:36
问题 I am blocked for hours now, I am trying to handle a button click inside a listview using the xml onClick attribute. Here is my result.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <TextView android:id="@+id/url" android:layout_width="0dp" android:layout_height="0dp" android:visibility="gone"/>

how do I take information from one private void and put it in another

放肆的年华 提交于 2019-12-11 19:29:14
问题 i want to take information from one private void and then put it into another I need to do this and cannot run them in the same section because I have been told that wont work with what i want the code to do. here is the code that isn't working its the dlg2.selectedPath that inst being recognised from the button private void where it needs to be. private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog dlg2 = new FolderBrowserDialog(); if (dlg2.ShowDialog() == DialogResult

Trouble with converting fixed-amount of for loops to parametrized amount

允我心安 提交于 2019-12-11 19:25:11
问题 I am trying to make a generator for Spirals being parametrized by the amount of dimensions the answer should have. Example on 2 dimensions (x, y) static void caller() { for (int t = 0; t < 10; t++) for (int x = 0; x <= t; x++) { int y = (t-x); printAllPossibleSigns(0, x, y); } } Example on 3 dimensions (x, y, z) static void caller() { for (int t = 0; t < 10; t++) for (int x = 0; x <= t; x++) for (int y = 0; y <= (t-x); y++) { int z = (t-x-y); printAllPossibleSigns(0, x, y, z); } } Example on

Why does one need to call the function in an Object (constructor) in order to use a method that uses .this (JavaScript)

纵然是瞬间 提交于 2019-12-11 19:13:32
问题 var setAge = function (newAge) { this.age = newAge; }; // now we make bob var bob = new Object(); bob.age = 30; bob.setAge = setAge; bob.setAge(50); console.log(bob.age); This works, but when I try to do this var setAge = function (newAge) { this.age = newAge; }; var bob = new Object(); bob.age = 30; bob.setAge(50); console.log(bob.age); it returns "bob.setAge() is not a function" in the compiler? 回答1: The second example doesn't work because you haven't defined setAge, as you have here bob

Conventional Programming: How do you return two Types of primitive ('int and 'string') from “get” method?

强颜欢笑 提交于 2019-12-11 19:09:05
问题 Trying to print out age and name of an Object using "get" method. However, my get method return type is string: public String displayProfile() { System.out.print(getName() + getAge()); Hence the error: This method must return a result of type String Here is my main method: if user enters '2' from the "menu" where (2 == profile) the program should display user's name and age . Side note: To select "friends" from menu, user will enter '3' (3 = friends). public static void main(String[] args) {

PHP Error: Fatal error: Call to undefined method

不打扰是莪最后的温柔 提交于 2019-12-11 19:07:59
问题 I'm having a problem with my Mail class. It was working before, but now i'm not sure what happened. here is the error: Fatal error: Call to undefined method Mail::sendTo() in C:\...\web\modules\register.php on line 30 My mail class: class Mail { public static $Headers = 'From:akshay@myemail.com'; public $sendtowho; public $subject; public $message; public $template; public function sendTo($who='') { $this->sendtowho = $who; } public function with($subj='',$template) { $this->subject = $subj;