Ana Suvari

Ranch Hand
+ Follow
since Aug 18, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ana Suvari

Peter Taucher wrote:

Ana Suvari wrote:The behaviour is C++ Iterators and Vectors. That should be a Java version of the first code I posted at the top.


And what exactly does the first (C++) code do? I haven't coded C++ since about seven or eight years, so please enlighten me...



I haven't taken C++ for a while but that does not stop the Java Prof for making this assignment. So, I have to assume that Java's Vector and Iterators are made different from C++ or the Java Prof would not be making us do this.

Here's the C++ code that it should simulate close to.




v.begin() should return an integer index to the first element. But I don't get how does myIter equal to v.begin() if it's an integer? The prof made it sound like it should be easy peasy but I guess I still don't have any ideas.

The myIter class should be able to iterate through each element in myVector and display each of them.

I am not seeing what the Prof wants me to do that she thinks is so easy.
13 years ago

Peter Taucher wrote:First of all you're in a Java forum. So maybe it would be a nice idea instead of posting C++ code to describe what behaviour you want to achieve with your code. And then it's always a good approach to use the API classes, like java.util.Vector.

An last but not least 'I get compiler errors' is only nice in liaison with a crystabl ball. Otherwise we need you to TellTheDetails.



I did describe what behaviour I am trying to achieve: I'm trying simulate C++ Vector and Iterator classes using Java.

I don't want to simulate Java's Vector and Iterator.

My purpose is to try to simulate C++'s Vector and Iterator using Java.

I'm sorry for posting code that won't compile. it merely is to show that I tried to work on it but I still can't simulate C++ code. I don't understand how to do this with Java if Java has no pointers.

The behaviour is C++ Iterators and Vectors. That should be a Java version of the first code I posted at the top.

13 years ago
I need to simulate the following C++ STL vectors and iterator code using Java:


But I am confused at how to do this? I know that there's no pointers in Java so I can't seem to get how can I make myIter point to myVector v?

I tried the following but I have compilation errors:







Please give me some ideas how can I make myIter = v.begin() and how can I print out myIter?

I've been struggling with this so I would appreciate some ideas.

13 years ago
Thanks so much for your explaination
13 years ago
Hey that's strange. I removed that <Integer extends Comparable> and now the error is gone .

I don't see how that could have caused the error. I'm glad the error is gone but I'm not happy that it wasn't something that I can explain and understand Java.

There's too much that I don't know. Still i long way to go.

Hoping for no more crazy errors that i can't explain.
13 years ago

Christophe Verré wrote:Why are you declaring T as <Integer extends Comparable> ? This hides the Integer class, and you're not using it anywhere. Remove it if you don't need it.



I was using it but then I got too many errors and realized I didn't know enough about how it's supposed to work to fix those errors so I removed most of it's usage.

But i'm still not sure how that is related to the error that I'm talking about.

The crazy thing is at one time it was able to compile. I'm not sure what happened but I didn't keep a back up.

I don't understand Java. I wish I could learn Java but it seems like I have a long way to go. C was easier.

Oh well. I tried. I failed but I tried.

Thanks anyways.
13 years ago
Please someone help me. Once I get this going, then I could really start on my assignment. It's incomplete because I can't get the basics tested.

I would try to finish all my functions but what is the point if i can't test it out.

I wish that there was an easier way to learn Java.
13 years ago

Christophe Verré wrote:

I originally had it without the "new" operator but I had the same error


Really ? Can you try again, and copy/paste the line which gives you that same error ?



Okay, I'll display my both files instead of just the piece. The error is on line 152 in T.java

T.java:



TreeNode.java
13 years ago

Henry Wong wrote:

Ana Suvari wrote:
Integer intResult = new Integer.parseInt(result); //error: cannot make static reference to non-static Integer



This is not a valid Java statement... When you use the new operator, it is expecting the class name and constructor parameters. And when you try to call a static method, it is not expecting the new operator to be used. There is no such a thing a trying to instantiate a call to a static method.

Henry



I originally had it without the "new" operator but I had the same error. I decided to put "new" because Integer is a class. With or without "new", i get the same error. How is result a static? It's not supposed to be. intResult isn't a static. How did one of those become static?

Thanks for your patience.
13 years ago
I get the same Java Error in at line 21: cannot make static reference to non-static Integer

for this line:
Integer intResult = new Integer.parseInt(result); //error: cannot make static reference to non-static Integer


or I tried using the primitive type int:
int intResult = result; //error: cannot make static reference to non-static Integer

but really I need to get it to be an object Integer

but i still get the same error.

What I am trying to do is read integers until a user enters Ctrl-C. But I am afraid writing this in Java doesn't seem be the same way as C.


(1) I would greatly appreciate some help in getting rid of error and (2) also how to make it stop requesting user input at Ctrl-C without getting exception error. Some example links would also be helpful.



I'm not very experience with Java. I know how to do it in a C program but Java seems much complicated to me anyways.



13 years ago
I don't want to change my code because I'm in a tight deadline.

I defined a subclass within another class but then I found out that I really need the subclass to be known at the top level because I need to control it's MouseListeners at the top level.

How to I return a CardLabel() class that is defined within HandPanel() class to the top level class?

CardLabel() class is NOT an instance of HandPanelPanel(). Instead it is subclass. I need the CardLabel() class to be known in the top level class so that I can control it in the Controller().

I'm so exhausted. I don't want to have change the way I have it but I need to controller the action of onclick.

public class HandPanel extends JPanel

public HandPanel(){

}



private class cardLabel extends JLabel implements MouseListener{

....

}

}


Please help. I'm stuck and haven't slept
13 years ago

Ana Suvari wrote:I don't understand what to do...The window class is the super class that calls creates an instance of JoinRoom. I can't just make the subclass called inside window as another parameter to the Controller. It doesn't make sense too. I need to make Window class know about it so then Controller will know about it.

public RoseRealTimeController(RoseRealTimeWindow window, JoinRoom jroom, String hostname, int portnumber)

Please help me someone. I'm really strugglinig I'm supposed to be working with my team but they abandoned me.

I'm in trouble if i can't figure it out.

13 years ago
I don't understand what to do...The window class is the top level. I can't just make the subclass called inside window as another parameter to the Controller. It doesn't make sense too.

public RoseRealTimeController(RoseRealTimeWindow window, JoinRoom jroom, String hostname, int portnumber)

Please help me someone. I'm really strugglinig I'm supposed to be working with my team but they abandoned me.

I'm in trouble if i can't figure it out.
13 years ago
Ok, that seemed to work when i put the buttons back in their classes like you said.

However, I still don't get the example tutorial. The Controller only has the window, hostname and portnumber as parameters and not any of my subclasses. Thus, i don't know how to access the button's action in a separate class.

In the Controller, How do i call the action class for getJoinButton() when its defined in the JoinServer class. It still needs to know the name of classes and procedures to control the button which are definied in separate classes and not the Window class that is passed in.

.

... Theres more but don't need to show all
13 years ago