[Solved] How to use 1 setter for multiple instance variables

I would suggest to make an int array to store your variables, so instead of: private int qz1, qz2,…. do private int [] quizValues; You can then get a value for a quiz: public int getQuizValue(int storePositionOfQuiz) { // check for outOfBounds! return this.quizValues[storePositionOfQuiz]; } If you want you can then initialize the quiz values … Read more

[Solved] python grammar mistake invalid syntax

One problem with your code is that the index n1 by definition does not exist in your list. Python lists indices start at 0, so a list with length 3 only has indices 0-2. mylist = [“a”, “b”, “c”] print(len(mylist)) # 3 print(mylist[3]) # IndexError! print(mylist[2]) # “c” Instead of this: n1 = len(p1) Try … Read more

[Solved] How to create a switch for a takeDamage method

If I understood your question correctly, you want something like this: public void takeDamage(int damage){ shield-=damage; if(shield < 0){ health+=shield; //shield is negative,so subtracts leftover damage from health if(health <= 0){ lives–; health=DEFAULT_HEALTH_VALUE; //replace with your own default values shield=DEFAULT_SHIELD_VALUE; } } } 0 solved How to create a switch for a takeDamage method

[Solved] Input from a file [closed]

You can read all data at a moment: with open(input_file, ‘r’, encoding=’utf-8′) as f: data = f.read() You can read all data line-by-line: with open(input_file, ‘r’, encoding=’utf-8′) as f: for line in f.readlines(): # todo smth solved Input from a file [closed]

[Solved] Using sub to reduce length of text [closed]

sub(“.*;\\s*”, “”, String) Explanation: .* – matches any number of characters at the beginning ; – matches the last ; \s* – matches zero or more white-space characters after the ; So the first expression matches everything up to the first non-blank character after the last ;. It is replaced with the empty string, so … Read more

[Solved] for each nested for each

You shouldn’t use nested for-each loops here. Try an indexed for on the listMain and store the result of each iteration in a kind of tuple. This tuple could be stored in a Map. As your friend mentioned, you could use a HashMap for this. Something like this should do the trick: ArrayList<Main>listMain = mainDAO.getlAllMain(Connection … Read more

[Solved] How can i load a link in other browser from web view?

Try this: webView.setWebViewClient(new WebViewClient(){ public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url != null && (url.startsWith(“http://”) || url.startsWith(“https://”))) { view.getContext().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } else { return false; } } }); 2 solved How can i load a link in other browser from web view?

[Solved] How can I get the sum, difference, quotient, product of two values and printed out in textview [closed]

add two EditText for getting two numbers then add four button for different operation like add/sub/mul/div. Get value of editText and Set onClickListener and write appropriate code in that. EditText firstNumber; EditText secondNumber; TextView addResult; Button btnAdd; double num1,num2,sum; firstNumber = (EditText)findViewById(R.id.txtNumber1); secondNumber = (EditText)findViewById(R.id.txtNumber2); addResult = (TextView)findViewById(R.id.txtResult); btnAdd = (Button)findViewById(R.id.btnAdd); btnAdd.setOnClickListener(new OnClickListener() { public … Read more