• Post Reply Bookmark Topic Watch Topic
  • New Topic

small question  RSS feed

 
Medrano Ryan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys hows it going, i just have a small question and mabye someone can shoot a reply or tell me how to get it going, im trying to compose a program that its main purpose is to click on certain parts of the screen at seperate intervals, i have this book called "head first java" and i really like it, but right now im about half way done with my c++ programing in easy steps book, so someone hit me up and see how i could start composing the program..
thanks guys

-Ryan
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch! We can help you best when you show code that almost works. Right now we can't tell if you are comfortable writing a main() method or looping and timing or everything right up to the "click" part.
 
Medrano Ryan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well since im just begining.. i know that in order to make an "object oriented" program i need to get out of main (well execpt the fact just to get the porgram running) and make sperate classes, but im sitting here thinking, that how and why would i use classes? maybe for the timing.. and the actual places to click on the screen? right now stan i wouldn't mind staying in main just because im new, thanks for the reply

-Ryan
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For now, stay in main();// Do it like this:


The trick is static keyword is alot easier to figure out in java.
 
Medrano Ryan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cool man thanks, but so verctor is the one i need to work with?
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear god no. For heaven's sake, use the combination of List and ArrayList; instead of "Vector victor = new Vector(10);" write "List victor = new ArrayList(10);".

Search for the difference between Vector and ArrayList, and it will become clear why Vector is hardly ever the class to go for.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime is quite right. He forgot to mention however, that you can never put a 1 into a List. At least not the way you have written it. Actually I don't think a List has a put method in the first place.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
He forgot to mention however, that you can never put a 1 into a List.

You couldn't in Java 1.4 and before. In Java 5 and up however, if you declare the list as a List<Integer>, then the compiler will allow it, using autoboxing.
Actually I don't think a List has a put method in the first place.

It doesn't, there are add and insert methods. put is a method of Map.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I said "at least not the way you have written it," I was hoping he would come back so we could get to List<Integer> . . .
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still confused on the purpose of this Vector/List with respect to the original post.
[ December 09, 2007: Message edited by: marc weber ]
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[marc weber:]   I'm still confused on the purpose of this Vector/List with respect to the original post.

Original poster wants to do object oriented programming. The procedural nature of main has left the orignal poster trying to get out of main(). I suggest any standard demo program, one that would be approved by the OO camp and make sure there is a way to put a main in it. Then do a new on the enclosing class and show how to call instance methods on the enclosing class.

Use the class of your choice or your own authorship, as should the original poster.
[ December 09, 2007: Message edited by: Nicholas Jordan ]
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicholas Jordan:
Then do a new on the enclosing class and show how to call instance methods on the enclosing class.


I beg your pardon? What does that mean? If you are going to put data into the class then instantiate it, you have either got only static data, which won't pass muster in Campbell's school of object-oriented programming, or you have lost all your data.

I think it would be best of we went back to Stan James' original and correct advice:
show code that almost works
Medrano Ryan: Please follow Stan's advice and post something you have got whether it works or net. Round here the C++ students are taught (quite correctly) to have as little code as possible in their main() method.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!