QCannot find symbol when calling class?Java Development

I am new to java and have a question about input validation. I am attempting to call two classes (by the names of ValidCustomerType and ValidSubtotal) that will validate the input of this application. The code for the main classes are as follows: Main Class: import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Scanner; public class InvoiceApp { [...]

QDouble assignment in pythonPython

Please see the code here move_from, move_to = [ (item['path'], prev_item['path']), (prev_item['path'], item['path']), ][item['op'] == ‘add’] What is assigned to move_from and move_to. It looks like double assignment, but don’t see two on the right (I am a non python programmer) I am trying to port to Javascript, how would it look like? Thanks.

QInsert string inside the head tagJavascript Questions

var c = <head></head><body></body> i want to insert base tag between head tag. The above head tag is not in html form its inside the variable, now i want to modify this c variable like shown below <head><base target=”_blank”/></head><body></body> Anyone knows…..

QAdd a file of strings into an arraylistJava Development

I’m trying to add this file into an arraylist which I will later compare to another arraylist. So far I have this but it is giving me a compiling error. It is saying that it cannot find the symbol .hasNext and . readLine. ArrayList<String> america = new ArrayList<String>(); while((infile2.hasNext())) { america.add(infile2.nextLine()); } Can someone help [...]

QPython regular expressions: changing conditional operatorsPython

In Python, I am trying to use a regular expression that replaces all less than (<) and less than and equal to (<=) expressions with the equivalent greater than (>) or greater than or equal to equivalent. For instance, “a < b” would be replaced with “b > a”. I believe my code for the [...]

QRun javascript code after angularjs route loadedJavascript Questions

I need to show an alert after a route has been loaded by angularjs. The piece of code to show the alert is in the view loaded asynchronously by angularjs: <script> alert(‘test’); </script> Once the view has loaded, I expect this to be run, but it does not. I know I can broadcast and tell [...]

QRandom Number Generation with constraints in any programming languagePython

I want to generate 150 random numbers with values as positive integers (1,2,3,4,5…..) such that sum of all random numbers is 270 and Prob[1] = 0.405 Prob[2] = 0.345 Prob[3] = 0.125 Prob[4] = 0.092 Prob[>=5] = 0.033 Basically, sum of all random numbers is fixed, probability is fixed and random number should take values [...]

QInheritance, NullPointerException concept of super()Java Development

Base Class: public class Base { private String baseMessage = “Hello!”; public Base() { printMessage(); } public void printMessage() { System.out.println(baseMessage.toString()); } } Derived Class: public class Derived extends Base { private String derivedMessage = “World!”; public Derived () { super(); } @Override public void printMessage() { super.printMessage(); System.out.println(derivedMessage.toString()); } public static void main(String[] args) [...]

QSVG rotation using JavascriptJavascript Questions

I have created an SVG image in an HTML page, and now I want to move the SVG shapes about using JavaScript buttons. The JSFiddle for my application is here : http://jsfiddle.net/johndavies91/xwMYY/ The buttons have been displayed but their functions aren’t being displayed upon clicking the buttons. The functions’ codes are as follows; function rotatex() [...]

QJavascript Prompt Validation?Javascript Questions

I want to prompt the user to enter a sport (baseball, football, soccer, or track). Let’s say I enter “Golf”. How do I get it to keep asking me to enter a sport until I enter one of the valid sports? The sport determines what field they play on. Below is my code. var sport [...]

QPython: Shoplist script and empty list count?Python

I am a complete beginner in python3. I took the script from wikibooks homepage and I changed it for my needs. The problem is that I do not know how to change script input words into numbers (etc. ‘str’ to ‘int’ and ‘int’ to ‘str’). Changed script: shoplist = [] def main(): while True: print() [...]

Qjs timestamp to readable format… need to replicate php functionJavascript Questions

I have come across a unique situation where I can no longer use php to format a timestamp and instead need to us jquery/js. in php : given (’2014-04-01 20:05:00′, ‘F jS, Y @ g:i a’) would return ‘April 1st, 2014 @ 8:05 pm’ // Date/time converter for strings function convertStringTime($timestamp, $format) { if ($timestamp [...]

QWhy do I get “cannot find symbol” using scanner when compiling? [on hold]Java Development

I’m learning java here, so as I wrote a simple program, I get an error every time I try to compile it. This is the error I get: Trivia.java:14: error: cannot find symbol ret = sc.nextline(); ^ The program is as follows: import java.util.Scanner; class GameStart { public static void main(String[] args){ Scanner sc = [...]

QVariable scoping when reassigning/changing global variablePython

I’m running into behavior in python which I’m sure is easily explained but still peculiar to me. I can run a function that attempts to “change” a global variable but does not succeed because the variable created is local: x = ‘n’ def make_up(letter): return letter.upper() print x >>> ‘n’ print make_up(x) >>> ‘N’ print [...]

QUsing reflection in an enumJava Development

I have an enum that implements an interface: public enum MyEnum implements MyInterface { ENUM1{ @Override public String myMethod(String inputString){ //blah } }, ENUM2{ @Override public String myMethod(String inputString){ //blah } } } How can I use reflection to call ENUM2.myMethod(inputString); ? I made an attempt at it. Method m = MyEnum.ENUM1.getClass().getMethod(“myMethod”, inputString); But that [...]

QHow can I store an AJAX response to a class property?Javascript Questions

I am creating a model-like Class that, when initialized, fires off an AJAX request. I want to store the response of that request as a property of the new object, so that I can use the data it returns. Problem is, the value of ‘this’ within the promise (.done) is the XHR object, not the [...]

QDjango 1.6 How to create a form with a datefield using a python dictionaryPython

I have the next form in Django 1.6: class TestForm(forms.form): first_date = forms.DateField(widget=SelectDateWidget(), required=True) name = forms.CharField(widget=forms.PasswordInput(), label=”Real Name”) I want to create an instance of this form in my view using a dictionary (bare with me, I HAVE to use a python dictionay here). Reading the documentation I found an example without DateField and [...]

QWhat's the best cache policy with Angular.js and chrome apps?Javascript Questions

So I have a dream. My dream is that my angular application waits as small amount of time as possible before rendering data for the user. I’m also imagining that users can use my application without a network connection. Based on this, I’m trying to have two levels of cache. They are (these are rough [...]

QHow to read specific lines in a file and insert them to a dictionary in python?Python

I have a text file with format : 2014-04-10 Arjun 22 Class 10 60 Anil 23 Class 09 85 2013-03-10 Jhon 21 Class 10 78 How should the code be, if I want the dictionary as shown : {’2014_Arjun’ : ['22','Class 10','60'],’2014_Anil’:['23','Class 09','85'],’2013_Jhon’:['21','Class10','78']}

QCannot cast from void to String in Java?Java Development

I am trying to save the error printed on the command line by (e.printStackTrace()) in a StringBuilder Variable which i then export to a txt file However i am getting an error cannot cast from void to String ? Can someone please explain to me why i cannot cast it to String and if there [...]

QHow do i implement javascript on my site?Javascript Questions

Ok, newbie question. I’ve written some javascript that I believe will work for my site. Total experience so far, codecademy.com. Do I just need to save a text file with a .js extension on the end? Then do the whole tag? Do I need a compiler?

QComparing Two ArrayLists for common items and deleting those items from one of those ArrayListJava Development

I have two arrayLists. One of them lists all of the presidents born in a state(List A). The second lists all of the presidents ever(List B). I have to compare the two and print out a list of presidents who were not born in any of our current states. Basically, they would not be in [...]

QPython Eve contains filterPython

There’s some way to return items that field contains some value? Eg. GET /people?contains=”foo” Return all persons that have the word ‘foo’ in the name. Thanks in advance

Qdifferent behaviour of hoisting of functionsJavascript Questions

function myFunction() { function myInternalFunction() { return 10; } return myInternalFunction(); function myInternalFunction() { return 20; } } alert(myFunction()); // What will this alert? The answer is 20. function myFunction() { var myInternalFunction = function() { return “Hello World.”; } return myInternalFunction(); var myInternalFunction = function() { return “Second Definition.”; } } alert(myFunction()); // What [...]

QJavascript or comparison arrays not working?Javascript Questions

var answers = ["hello", "my name is", "how are you?", "what is your name?", "how much does it cost?"]; var answers2 = ["hi", "my name is", "are you well?", "what's your name?", "how much is it?"]; $(“#submmit”).click(function() { var totalYes=0; function checkAnswers() { for(var i=0; i<answers.length; i++) { var userAnswer = document.getElementById(“b”+i).value; if(userAnswer===(answers[i] || answers2[i])) [...]

QLastfm API – array inside array JAVASCRIPTJavascript Questions

I want to make an array that contains another array inside. I insert an username and i want each neighbour (limit 10 neighbours) to have their top 5 bands. I want an array that has each neighbour and each has 5bands. The function getNeighbourTop receives the username of the neighbour (this part is working well) [...]

QIs there a Java IDE that supports the same package and class names?Java Development

everybody. I have a Java Eclipse project. It contains many packages, and the class names can be the same with the package, just like: org.a a.java <——— this class is org.a.a b.java org.b a.java org.a.a <———- this package is also org.a.a a.java b.java When compiling the project, Eclipse reports error: The type “xxx” collides with [...]

QRegular expression: Preceding token is not quantifiablePython

I have a regular expression (-|+)?, but when I ran it on regex101.com I get the error: +: Preceding token is not quantifiable What does the error mean? Thank you

QIteration to update 2 dimensional arrayPython

Hi so essentially I have the basic text file: 3 1 0 1 0 1 0 1 1 1 And I’m trying to create a 2 dimensional array that contains the values as integers. My code so far is: import numpy as np f = open(‘perc.txt’, ‘r’) n = f.readline() j = 0 dim = [...]

QHow to check if List<E> meets requirements of another List<E>Java Development

Is there a way that I can check if one list meets the requirements of another? I have a list source and a list destination. The types aren’t known yet, which is why they’re generic. I’m trying to find a way where it could check if the elements in source would match the type of [...]