how to create a destroyer object

How to create a destroyer object?

Glory to the Ottoman Empire!

7 Replies

Like this:

[code=java]public class Destroyer extends Unit {

private int hitpoints;

private double damage;

private String location;

public Destroyer() {

hitpoints = 50;

damage = 8.0;

location = "New York";

}

public Destroyer(int hitpoints, double damage, String location) {

super(unitName);

this.hitpoints = hitpoints;

this.damage = damage;

this.location = location;

}

public int getHitpoints() {

return hitpoints;

}

public void setLocation(String newLocation) {

location = newLocation;

}

public String toString() {

return armyNumber + " Destroyer Flotilla (" + country + ")";

}

}[/code]I didn't take CSA for nothing.

Stay Sweet!

Are you trying to spawn units on the map? Is this even legal?

Aeroplanes are interesting toys but of no military value.
— Marshal Foch
A pretty mechanical toy [...] the war will never be won by such machines.
— Lord Kitchener, on tanks

Lord Crayfish wrote:

Are you trying to spawn units on the map? Is this even legal?
No lol. I just noticed how the OP said destroyer "object" instead of "unit" which reminded me of creating an object in Java.

I can't use it to spawn units on the map (or can I?)

Stay Sweet!

Taffyta Muttonfudge wrote:

I can't use it to spawn units on the map (or can I?)
I should bloody well hope not.

Glad this was a joke.

Aeroplanes are interesting toys but of no military value.
— Marshal Foch
A pretty mechanical toy [...] the war will never be won by such machines.
— Lord Kitchener, on tanks

Omg pls try it I need to know if it works


CarKing the 6th of the Abrahamic Caliphate

(Immediately spawn 10000 RRGs against USSR)

Looking for improvement.

Taffyta Muttonfudge wrote:

Like this:

[code=java]public class Destroyer extends Unit {

private int hitpoints;

private double damage;

private String location;

public Destroyer() {

hitpoints = 50;

damage = 8.0;

location = "New York";

}

public Destroyer(int hitpoints, double damage, String location) {

super(unitName);

this.hitpoints = hitpoints;

this.damage = damage;

this.location = location;

}

public int getHitpoints() {

return hitpoints;

}

public void setLocation(String newLocation) {

location = newLocation;

}

public String toString() {

return armyNumber + " Destroyer Flotilla (" + country + ")";

}

}[/code]I didn't take CSA for nothing.

Shhhh don't reveal the coding secrets

Post a Reply

Please log in to post a reply.

Back to Questions and Answers
Quick Launch