Original Post
Hi there,
Been trying to get my head around initializing and getting data from an object from other classes, im using Java.
Sorry if this explanation isnt the best, i'm still trying to get my head around this but hope you can help me.
If i have a class Enemy with a get method inside to get data say from a hashtable and then in another class called enemy_list i initialize an object for eg
Enemy enemy = new Enemy();
and call the method to get the data
enemy.get()
that will get any data that has been put into enemy. Now my issue is this If i have yet another class say creatures and i want to get data from class enemy (like name,level) to put both datas together i cant initialise another enemy object as that will create a new enemy and wont have the same data as the enemy_list class i want to get an existing enemy. How do i get access to the existing data in the enemy class without having to do another Enemy enemy = new Enemy() in the creatures class.
Been trying to get my head around initializing and getting data from an object from other classes, im using Java.
Sorry if this explanation isnt the best, i'm still trying to get my head around this but hope you can help me.
If i have a class Enemy with a get method inside to get data say from a hashtable and then in another class called enemy_list i initialize an object for eg
Enemy enemy = new Enemy();
and call the method to get the data
enemy.get(
that will get any data that has been put into enemy. Now my issue is this If i have yet another class say creatures and i want to get data from class enemy (like name,level) to put both datas together i cant initialise another enemy object as that will create a new enemy and wont have the same data as the enemy_list class i want to get an existing enemy. How do i get access to the existing data in the enemy class without having to do another Enemy enemy = new Enemy() in the creatures class.