how can I o this code

Write a java class called "Ship". Ship can have id, number of sailors, and speed.

-Apply information hiding / encapsulation in defining Ship data members.

-Provide appropriate number constructors for this class.

-Override toString method.

-Override equals method.

-Write the main method, instantiate one object (id =100, number of sailors =20, speed = 300), and print it.

Please help me.

[432 byte] By [55_ooa] at [2007-10-3 5:20:21]
# 1
*sigh*I give up.
warnerjaa at 2007-7-14 23:27:15 > top of Java-index,Java Essentials,Java Programming...
# 2
> Please help me.With what? I didn't see any question, just the assignment text. Whatpart of the solution is troubling you? What did you do sofar? Did thecompiler complain? Weren't the results as you expected?kind regards,Jos
JosAHa at 2007-7-14 23:27:15 > top of Java-index,Java Essentials,Java Programming...
# 3

> Please help me.

Help you with what? Nobody is going to write your homework for you.

If you don't know any Java now would be a good time to get started learning http://java.sun.com/docs/books/tutorial/java/index.html

If you do know Java and are getting stuck with a particular portion of your assignment then please specify what that problem is.

cotton.ma at 2007-7-14 23:27:15 > top of Java-index,Java Essentials,Java Programming...
# 4

This will get you started.

public class Ship

{

private String id;

private int soulsOnBoard;

private double speed;

public Ship(String id)

{

this.id = id;

}

public Ship(String id, int sailors)

{

this.id = id;

this.soulsOnBoard = sailors;

}

public Ship(String id, int sailors, double speed)

{

this.id = id;

this.soulsOnBoard = sailors;

this.speed = speed;

}

public String toString()

{

return "The ship " + id + " has " + soulsOnBoard

+ " souls on board and can move at a speed of " + speed + " knots";

}

//Probably want a hash code method too

public boolean equals(Object ship)

{

if ( this == ship )

return true;

if ( !(ship instanceof Ship) )

return false;

Ship s = (Ship) ship;

boolean equal = true;

if ( !this.id.equals( s.getId() ) )

{

equal = false;

}

if ( !(this.soulsOnBoard == s.getSoulsOnBoard()) )

{

equal = false;

}

if ( !(this.speed == s.getSpeed()) )

{

equal = false;

}

return equal;

}

public String getId()

{

return id;

}

public void setId(String id)

{

this.id = id;

}

public int getSoulsOnBoard()

{

return soulsOnBoard;

}

public void setSoulsOnBoard(int soulsOnBoard)

{

this.soulsOnBoard = soulsOnBoard;

}

public double getSpeed()

{

return speed;

}

public void setSpeed(double speed)

{

this.speed = speed;

}

}

Norweeda at 2007-7-14 23:27:15 > top of Java-index,Java Essentials,Java Programming...
# 5
> This will get you started.Please don't do that, it doesn't help the OP one bit.kind regards,Jos
JosAHa at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 6
> Help you with what? Nobody is going to write your> homework for you.Except JerkWeed.
warnerjaa at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 7
I'm not trying to HELP him. I'm answering his question. What do I care if he fails his next test (which he will if he just uses this code)I think that's a much better way to weed these people out.
Norweeda at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 8
> > Help you with what? Nobody is going to write your> > homework for you.> > Except JerkWeed.JerkWeed? Nice. "The ocean called, they're running out of shrip"
Norweeda at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 9
> JerkWeed? Nice. "The ocean called, they're running> out of shrip"Then please by all means jump in so that the supply will be at least temporarily replenished.
warnerjaa at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 10

You seem to be new to insulting people?

Carry on your meager existance.

I don't see what's so wrong with answering these post adn why you guys care so much. Now he's gone and dumber for it. Maybe he'll learn it some day, maybe he won't. Maybe this answer will be helpful to someone, maybe it won't, but it has to be better than the "Don't post homework" for the 1,000,000 th time.

Norweeda at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 11

> You seem to be new to insulting people?

>

> Carry on your meager existance.

>

> I don't see what's so wrong with answering these post

> adn why you guys care so much. Now he's gone and

> dumber for it. Maybe he'll learn it some day, maybe

> he won't. Maybe this answer will be helpful to

> someone, maybe it won't, but it has to be better than

> the "Don't post homework" for the 1,000,000 th time.

Except that...

on the "weeding out" front experience and common sense would indicate that while the OP may well fail and be weeded out there will be other people who will read this thread and think that it is acceptable and appropriate for them to post their own laundry list of requirements and have someone write the code for them.

It isn't an appropriate way to learn. And it's not acceptable professionally. Do you not place some value on your own code? Why should you provide for free what you would normally charge for? Assistance is one thing. Providing full code something else entirely. When you do this it devalues your own work.

Further it's not "Don't post homework" it's "don't expect someone to do your work for you". Those are not the same.

cotton.ma at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 12

> I don't see what's so wrong with answering these post

> adn why you guys care so much. Now he's gone and

> dumber for it. Maybe he'll learn it some day, maybe

> he won't. Maybe this answer will be helpful to

> someone, maybe it won't, but it has to be better than

> the "Don't post homework" for the 1,000,000 th time.

There can be a happy medium: Don't merely brush off the poster meaninglessly, but neither give him the entire answer all in one go. Instead, give enough information to let the poster help himself.

I can't speak for anyone else, but I care because I want to help people.

Sure, it can be hard: Some people are unwilling to learn, some don't speak English very well, some are simply cursed with merely average intelligence, but if you don't like it then you don't have to post.

Mr_Evila at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 13
> the "Don't post homework" for the 1,000,000 th time.But less fun.
CeciNEstPasUnProgrammeura at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 14

Jerkweed,

I know this is too much for you to grasp, but just try.

If by chance an eejit gets enough of your kind of "help" and actually graduates, and also cheats his way thru an interview (like so many eejits try here by trying to get common interview questions and answers rather than by actually having -gasp- knowledge)...

Then that eejit might end up working next to me and I might have to expend my energy righting his wrongs. I don't want to do that.

The company might take a loss by having such eejits "working" there, and this may affect my raises and bonuses.

The industry already has enough incompetents working in it. It's full up.

So I and many others here have a serious issue with your tactics here.

warnerjaa at 2007-7-14 23:27:16 > top of Java-index,Java Essentials,Java Programming...
# 15

We'll see how it works out. Some of the homework that gets posted here can be kinda fun (most isn't). I generally find myself writing that code out when I'm bored anyway so why not post it.

As for devaluing my own code. I think not. If someone were to make a post asking for a batch framework or a document composition module I'll think twice about posting the code, but just about anyone that's spent a few days with java can code these assignments that get posted. I'm in no way devaluing my own work.

I see your point and it'll be interesting to see if there's an influx of homework posters. I think since it's the start of the school year we're going to be seeing plenty of them anyway.

Norweeda at 2007-7-21 10:59:23 > top of Java-index,Java Essentials,Java Programming...
# 16

serious issues.

If someone can cheat their entire way through school and land a job they should be a manager.

hell if a company hires that person they deserve them. If you're actually worried about your company hiring these types of people I suggest you start looking for a new job.

Norweeda at 2007-7-21 10:59:23 > top of Java-index,Java Essentials,Java Programming...
# 17

> hell if a company hires that person they deserve

> them. If you're actually worried about your company

> hiring these types of people I suggest you start

> looking for a new job.

On it's face this seems a fine idea. However in a great majority of companies most of the technical hiring and other decisions are made by non-technical managers and *gasp* recruiters. So it's pretty common to find a wide variance in competence in every workplace. And while I don't think that this is limited to IT by any means it's probably worse than other fields because it's so difficult for outsiders to measure and gauge competency levels.

cotton.ma at 2007-7-21 10:59:23 > top of Java-index,Java Essentials,Java Programming...
# 18

> serious issues.

>

> If someone can cheat their entire way through school

> and land a job they should be a manager.

>

> hell if a company hires that person they deserve

> them. If you're actually worried about your company

> hiring these types of people I suggest you start

> looking for a new job.

Well, there is certainly a plentiful supply of incompetents already in the workforce. They somehow managed to get in, and we just don't need more "help" of your type getting them in there. Duh. I think you need to retake Common Sense 101, jerkweed.

warnerjaa at 2007-7-21 10:59:23 > top of Java-index,Java Essentials,Java Programming...
# 19
Since you've gone, my heart said something's wrong.How long can this keep going on?I'm still blue over losing you.What else am I gonna do?I'm building bridges straight to your heart,And all of this distance won't keep us apart
cotton.ma at 2007-7-21 10:59:24 > top of Java-index,Java Essentials,Java Programming...
# 20

Welcome every one,

Thanks for all who reply me but at the same time I am sorry to write the question because many of you are angry.

I am very sad for some reply And I want to Know what JerkWeed

and I will not work for any company and just I want to pass the course because I tried many times to write many codes but I faild and alway I have bid proplem in starting in code even it is very simple

Thanks

55_ooa at 2007-7-21 10:59:24 > top of Java-index,Java Essentials,Java Programming...
# 21
> just I want> to pass the course because I tried many times to> write many codes but I faild and alway I have bid> proplem in starting in code even it is very simple > > Find yourself a tutor.
cotton.ma at 2007-7-21 10:59:24 > top of Java-index,Java Essentials,Java Programming...