@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5



Comments:

<0> mm
<1> many instances can change the value of counter
<1> and they all see the same change
<1> if instance a does counter = counter + 1
<1> then if instance b reads counter it gets the value 2
<0> this is if the counter is non-static?
<1> no, if it is static
<1> just remember, static = part of cl***
<1> non static = part of object
<1> another easy way to remember is: the main method is static
<0> someone should have explained that to me earlier
<1> yes
<1> its very important to know
<0> guess so
<1> the main method is the starting point for your application
<0> then.. if i should instance the cl*** before using the methods, how do i code that?



<1> no object has yet been created
<0> mhm, so far so good
<1> so in the main method you can create objects
<1> and call their methods
<0> right
<1> which operate on the object attributes
<1> and sometimes all these objects need to share some common item
<1> so you add a static variable to the cl***
<0> like a getMethod
<1> so, do you know the solution to your problem now?
<0> i'm a bit closer :)
<0> and i've fitted some holes in my knowledge
<1> have you had previous programming experiences?
<0> so, i should instance the cl*** where the method is?
<0> no, only PHP
<1> yes
<0> so, on the line above where i should use the method, i have to write something like "object = new cl***" ?
<1> nameofcl*** variablename = new nameofcl***(parameters);
<0> ah, thanks
<0> very good explaining btw
<0> i appreciate it
<1> like JButton mybutton = new JButton("OK");
<1> and then I can do stuff like mybutton.setLabel("CANCEL");
<0> hm, what if the cl*** is already instanced? and i only want 1 object of each cl***?
<1> then don't instantiate it again
<0> then the method is free to use as is?
<1> yes
<0> wonderful
<0> then i should ignore the error msg complaining about making a non static reference ?
<1> no
<1> you won't get that error anymore
<0> the error is in the editor window
<0> before it's compiled
<0> (eclipse)
<1> then the code is wrong
<0> oh
<1> you can upload your code to javafaq.mine.nu whiteboard
<0> just a second
<0> Rob_uknow: http://javafaq.mine.nu/lookup?7&wb=true roboplayer-cl***: Board.checkAvailable(Game.getRoboChar) <--- this method
<0> all new this white board?
<1> no
<0> ok
<0> thought about the 7-id
<0> but nevermind :p
<0> i didnt mean to upload the game-cl***. never mind that too
<1> checkAvailable is not static
<0> no, it's not
<0> so.. easy way: make it static?
<1> public cl*** RoboPlayer { Board board = new Board(); public void makeMove() { ..board.checkAvailable(..) } }
<1> no
<1> thats bad programming style
<0> i think so too
<1> you are trying to program procedural in an object oriented language
<0> hehe, ive been using PHP for ages
<1> it might help if you draw a cl*** and object diagram
<0> already done that. i have a chart (brain storm) over cl***es and suggestions to methods too
<1> Game shouldn't be accessed static aswell
<0> game is the "top" cl***, which make everyting start
<1> the best thing to do: remove all static methods and attributes, except the main method ofcourse
<0> mhm
<0> i agree



<1> looks fine
<1> Game should have a public static void main(String args[]) method
<1> that creates an instance of Game
<1> and Game can hold object references to Board and RoboPlayer
<0> so, first line in that method is "new game" ?
<1> possible
<0> ok
<1> or let the Game constructor handle that
<0> ah
<0> btw, this is a simple tic tac toe-game
<1> public cl*** Game { private Board board; private RoboPlayer roboPlayer; public Game(){ startNewGame(); } public void startNewGame() { board = new Board(); roboPlayer = new RoboPlayer(); board.addPlayer(roboPlayer); } public static void main(String args[] { new Game(); } }
<1> just an example
<0> thank you :)
<1> the Game cl*** could handle the game logic
<0> uhm.. the Board-cl*** does.. is that bad?
<1> the Board can check if moves are valid
<0> ok
<1> maybe also do the presentatino of the Board on screen
<1> presentation
<0> like, checkAvaiable?
<1> yes
<1> its important to seperate Model, View and Controller
<0> there's very little logic at this time. there's not supposed to be any AI yet
<0> examples for model, view and controler?
<1> the Board is a model, it just contains data, controller modifies the model, the view presents the data
<1> thats how you create a clean application
<1> the whole concept is known as MVC
<0> sounds clever
<0> :)
<1> it is
<1> its the only way to avoid spagetthi code
<0> we're drilled a lot in high cohesion and low coupling too
<1> yeah
<1> lose coupling
<1> you can then easily replace the model
<0> mhm
<1> or the view
<0> or extend it
<0> mhm
<1> maybe you can even add a html view
<0> maybe
<1> and make it a web application
<0> would be neet for my exam
<0> to my*
<1> what study are you following?
<0> bachelor in automatation technics
<1> automation of what?
<0> development of robots and simulators etc
<1> whats the scope?
<1> oke
<0> we're using java as example language for OOP
<1> we call it cognitive science
<0> nice term
<1> it also involves psychology
<0> and the ability to think?
<0> you're from holland?
<1> more how we think and how to use that knowledge to build robots
<1> yes
<0> norway here
<0> private Board board; <--- what does that one do?
<0> instances?
<1> it means Game holds an attribute of type Board
<1> and the attribute is private
<1> other cl***es can't access Game.board
<0> ok, thanks
<1> one thing
<0> mhm?
<1> if you never instantiated board
<1> and you try to invoke methods on it, you get the following exception: NullPointerException
<0> i will remember that
<1> so if you see that, you know whats wrong
<0> hehe
<1> and trust me, you will see it
<0> i bet :)


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #java
or
Go to some related logs:

tent_yew_inn
#javascript
faniello paceville
#c++
nytanjel
SCOTTRADE elite patch
#linuxhelp
#AllNiteCafe
#linux
pear.exe



Home  |  disclaimer  |  contact  |  submit quotes