|
Missed that casting requirement.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Probably the first time I've seen you make a mistake.
|
|
|
|
|
You cannot add a Radial object to a List of Tire s, only a Tire object. If you were allowed to then you could start trying to call Radial methods, or access Radial properties on Tire objects, which is not possible.
|
|
|
|
|
Hey there, it seems like you're using the wildcard operator "?" and trying to use a method which is modifying the list at the same time.
Now I am no expert but I think the above combination cannot be used since if you want to add something to a generic collection then as far as I remember you have to use the "super" keyword with the wildcard operator to let the compiler stop bothering you from adding modifying your collection and with the keyword super you'll have to change the declaration to one hierarchical level lower as well.
Hope this helps, pardon me if I got it wrong though.
Cheers.
modified 8-Feb-18 1:11am.
|
|
|
|
|
I'm slowly learning Javascript, and am trying to error trap this statement to determine if the file exists. My webcam writes a snapshot every x amount of seconds and I want to try to display the latest snapshot. Synchronizing the time from camera to server, to user is impossible, so I want to run a loop to check for the latest file, then display it.
Anyway, error trap for this statement. That would throw an error if the file didn't exist
document.write('')
I played with the TRY function, but it didn't detect an error.
dsp
|
|
|
|
|
Member 13508034 wrote: I'm slowly learning Javascript Well the first thing you need to learn is that Javascript is not the same as Java.
|
|
|
|
|
yea, figured that out, but still hoping there is a way.
|
|
|
|
|
And this still has nothing to do with Java. Please use the correct forum.
|
|
|
|
|
|
|
No, because JavaScript cannot access the hard drive so it won't be able to determine if the file exists or not.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hello! I'm having a bit of trouble with 2-dimensional arrays. Currently, I am using netBeans 8.0.
I don't believe I need a loop to do what I'm trying to achieve, but nonetheless I'm stuck. Here is the code for reference:
<pre>
package nb.test.gamepackagev1;
import edu.sjcny.gpv1.*;
import java.awt.Color;
import java.awt.Graphics;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class Homework4 extends DrawableAdapter
{ static Homework4 ge = new Homework4();
static Character[][] parade = new Character[4][2];
static int[][] aNum = new int[4][2];
static GameBoard gb = new GameBoard(ge, "Homework 4 by Sam Tahiri");
public static void main(String[] args) throws IOException
{
showGameBoard(gb);
int newX, newY;
for (int i = 0; i < parade.length; i++) {
parade[i][0] = new Character[4][2];
newX = aNum[i][0];
newY = aNum[i][1];
parade[i][0].setX(newX);
parade[i][1].setY(newY);
}
readArray();
}
public static void readArray() throws IOException {
File fileObj = new File("Array.txt");
if (!fileObj.exists()) {
System.out.println("File does not exist");
}
else {
Scanner fileIn = new Scanner(fileObj);
for (int i = 0; i < aNum.length; i++) {
int x = fileIn.nextInt();
int y = fileIn.nextInt();
System.out.println(x + " " + y);
aNum[i][0] = x;
aNum[i][1] = y;
for (int j = 0; j < parade.length; j++) {
parade[i][0].setX(x);
parade[i][1].setY(y);
}
}
}
System.exit(0);
}
public void draw(Graphics g) {
for (int i = 0; i < parade.length; i++) {
parade[i][0].show(g);
parade[i][1].show(g);
}
}
}
Ultimately, what I would look to do is to place the values of the array aNum[4][2] into each of the 4 objects of parade. The file, Array.txt, has 4 rows of 2 columns, therefore, 4 sets of [x][y] coordinates for the 4 objects I would like to create.
How can I place these values into said objects?
For example, if the first line of the array aNum is 120, 150, then the first object, parade, would be located at (120, 150) on the GameBoard. Thank you so much for helping me out!!
|
|
|
|
|
just give me an ideas or else if u know please send a sorce code.
please
|
|
|
|
|
Generically for all possible cases it is not possible because html need not be rigorously defined.
And there are other general problems such as what one is supposed to do with links and images during the conversion.
Further just converting it to XML generically isn't generally useful. One normally expects a certain format of some sort.
So if one wants to proceed one should define the following
1. What is allowed. Both as 'legal' html, and what data will be converted.
2. Use an html parser (HTML library)
3. Provide a source log both errors found and content for further analysis but otherwise skip it
4. Determine how to convert valid attributes to XML. The XML that was previously decided on
5. Get a XML library and use it to create the XML
|
|
|
|
|
Can we convert HTML to XML like this,First Can we convert HTML into XHTML and then to XML.
Is it possible?
|
|
|
|
|
Yes, it is possible, but it will require you to write the code.
|
|
|
|
|
|
Member 13501540 wrote: How? By reading the HTML, deciding which tags you want to keep, and using them to create the XML. There are libraries to read HTML and write XML, so all you need is to work out what needs to be transformed.
|
|
|
|
|
Well,thanks.
|
|
|
|
|
Create a function :
1. Int fact (int y) - to return the factorial of y .
2. Void printspecial() - by ivoking the function fact () , print all special numbers between s (start limit) and l ( last limit). The function reads starts (s) and last (l) limits. ( If sum of factorial of each digits of a numbers is equal to the number itself , the number is special ) .
Exp : input n = 145 = 1! +4! +5!= 1+24+120= 145, so 145 is special number .
Write a function Print () to I put start and end limits and by ivoking suitable function and print special numbers between start and end limits .
|
|
|
|
|
Sorry, we don't do your homework for you. Your homework is for you to learn stuff, not for us.
Try it yourself. If you get stuck somewhere in the middle feel free to ask a more specific question.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Jbdomnic123 wrote: Hi all can anyone solve this for me plz in java
Yes I can solve it. I would expect others can as well especially if they already know what a factorial is.
|
|
|
|
|
Not sure what's going wrong with my code-any suggestions? This is a basic calculator in Android Studio. It needs to be able to do multi-number operations(using order of operations). Currently, if you enter 2+2*6, it'll only do 2*6. Also, when you hit the Clear button, the 0 from the display stays tacked on, and I'm not sure how to get rid of it.Thanks!
package com.example.10012698.calculatorproject;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button button0, button1, button2, button3, button4, button5, button6,
button7, button8, button9, buttonadd, buttonsubtract, buttonmultiply,
buttondivide, buttonequals, buttonclear;
TextView display;
String displaytext="";
double result;
double x, y;
ArrayList<String> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button0 = (Button) findViewById(R.id.button0);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
button9 = (Button) findViewById(R.id.button9);
buttonadd = (Button) findViewById(R.id.buttonadd);
buttonsubtract = (Button) findViewById(R.id.buttonsubtract);
buttonmultiply = (Button) findViewById(R.id.buttonmultiply);
buttondivide = (Button) findViewById(R.id.buttondivide);
buttonclear = (Button) findViewById(R.id.buttonclear);
buttonequals = (Button) findViewById(R.id.buttonequals);
display = (TextView) findViewById(R.id.display);
display.setOnClickListener(this);
list = new ArrayList<>();
}
public void onClick(View view)
{
if(!(view.equals(buttonclear)&&!(view.equals(buttonequals))))
{
display.setText(display.getText()+""+((Button)view).getText());
if(displaytext.equals("0"))
{
display.setText(" ");
}
if(view.equals(buttonclear))
{
display.setText(" ");
}
if(view.equals(buttonequals))
{
displaytext= displaytext.substring(0,displaytext.length()-1);
StringTokenizer operators= new StringTokenizer(displaytext, "+-*/",true);
while(operators.hasMoreTokens())
{
list.add(operators.nextToken());
}
for(int j=0; j<list.size()-1; j++)
{
if (list.get(j).equals("*") || list.get(j).equals("/"))
{
x = Double.parseDouble(list.get(j - 1));
y = Double.parseDouble(list.get(j + 1));
if (list.get(j).equals("*"))
{
result+=(x*y);
}
if (list.get(j).equals("/"))
{
result+=(x/y);
}
}
}
for(int k=0;k<list.size()-1;k++)
{
if (list.get(k).equals("+") || list.get(k).equals("-"))
{
x = Double.parseDouble(list.get(k - 1));
y = Double.parseDouble(list.get(k + 1));
if (list.get(k).equals("+"))
{
result+=(x+y);
}
if (list.get(k).equals("-"))
{
result+=(x-y);
}
}
}
}
display.setText(""+result);
}
}
|
|
|
|
|
Your code is not clear to understand, you need to try a bit more diagnosis to narrow down where the problem is. Also, this question (and the one below) really belong in the Android forum[^].
|
|
|
|
|
Member 13476776 wrote: Currently, if you enter 2+2*6, it'll only do 2*6
I don't believe that the code you posted does that.
Member 13476776 wrote: displaytext= displaytext.substring(0,displaytext.length()-1);
The code you posted never sets displaytext. So it will always be empty. You should have been getting the value from 'display' (presumably.)
Member 13476776 wrote: list.add(operators.nextToken());
You never clear 'list'. That is going to be a problem. I doubt that 'list' should even exist anywhere except the method that parses the result.
You never clear 'result'
Your algorithm is incorrect. It does the following
1. Start = 2+2*6
2. Parse multiplication/division: result += '2*6'
3. Parse addition/subtraction: result += '2+2'
That would leave result=16 (should be 14).
|
|
|
|