• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Help on POO

Shh, quiet, you might piss somebody off
Developer
Joined
Dec 23, 2011
Messages
1,797
Reaction score
2,169
i'm transfering my Domain2 Editor Tool ( perfect world ) to OO, but i can't use variables from the object why ?
on Netbeans IDE, he say cannot find symbol, Symbol: timestamp class, <identifier> expect


Domain2.java
Code:
package com.company.Structure;
public class Domain2 {
    
        public int timestamp;
	public float unknown1;

	public int zones_count;

	public Zones[] zones;

	public int battletime_count;

	public BattleTime[] battletime;

	public int timemax;
        
        public Domain2(){
        }
}

LoadClient.java
Code:
package com.company.Structure;
import com.company.Utils.BinaryReader;
import com.company.Utils.BinaryWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


public class LoadClient {
    
    public Domain2 domain;
    public Domain2 values;
    int i;
    int j;
    
    public LoadClient(BinaryReader br) throws IOException {
        this.domain = new Domain2() {
            		timestamp = br.ReadInt32();
			unknown1 = br.ReadSingle();
			zones_count = br.ReadInt32();
			zones = new Zones[this.domain2.zones_count];
        };
        
    }
    
}
 
Last edited:
Junior Spellweaver
Joined
Oct 27, 2008
Messages
165
Reaction score
89
If you use "new Domain2(){}, you create an array of Domain2, where in your example timestamp is not an object of type Domain2.
PHP:
Domain2  domain1 = new Domain2();
Domain2  domain2 = new Domain2();
Domain2  domain3 = new Domain2();
Domain2 myDomain[]= new Domain2() {domain1, domain2, domain3, etc};

The proper use to create and initialize Domain2 is:
PHP:
this.domain = new Domain2();
this.domain.timestamp = br.ReadInt32();
this.domain.unknown1 = br.ReadSingle();
this.domain.zones_count = br.ReadInt32();
this.domain.zones = new Zones[this.domain2.zones_count];
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
Is anyone else enjoying the fact this thread uses the term 'POO' instead of 'OOP'? Lol, I love it! It should have been called POO from the beginning.
 
Joined
Aug 10, 2011
Messages
7,399
Reaction score
3,308
Use a constructor like:

Code:
public class MyClass
{

private int width;
private int height;

public MyClass(int width, int height)
{
this.width = width;
this.height = height;
}

public int getWidth()
{
return width;
}
}

and then you can instantiate it like:

Code:
MyClass someObject = new MyClass(10, 50);

System.out.println(someObject.getWidth()); //Prints 10
Is anyone else enjoying the fact this thread uses the term 'POO' instead of 'OOP'? Lol, I love it! It should have been called POO from the beginning.

OOP object oriented programming.
functional programming isn't called PF. It makes no sense. OOP is the correct name for it.
 
Junior Spellweaver
Joined
Oct 27, 2008
Messages
165
Reaction score
89
Is anyone else enjoying the fact this thread uses the term 'POO' instead of 'OOP'? Lol, I love it! It should have been called POO from the beginning.

In my language is called POO(Programare Orientata pe Obiecte) which is Translated version of OOP.

Since the OP is from Brazil, in Portuguese is Programação Orientada a Objetos(used google translate)
 
• ♠️​ ♦️ ♣️ ​♥️ •
Joined
Mar 25, 2012
Messages
909
Reaction score
464
Is anyone else enjoying the fact this thread uses the term 'POO' instead of 'OOP'? Lol, I love it! It should have been called POO from the beginning.
And you just called object oriented programming literally poop ...

functional programming isn't called PF. It makes no sense. OOP is the correct name for it.
It's rather called PP (procedural programming) and yes, it sounds like "pee pee". So the chapter is closed, I guess.
 
Shh, quiet, you might piss somebody off
Developer
Joined
Dec 23, 2011
Messages
1,797
Reaction score
2,169
sorry not updated thread
my code now works fine

Code:
public class LoadClient {

    public Domain2 domain;
    int i;
    int j;

    public LoadClient(BinaryReader br) throws IOException {
        this.domain = new Domain2();
        this.domain.timestamp = br.ReadInt32();
        this.domain.unknown1 = br.ReadSingle();
 
Back
Top