Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Pl help with my class assingment

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Pl help with my class assingment

    I messed up with my class assignment. Pl help me i did some so far.
    File Ship
    // public class Ship
    {
    	//fields
    	private String name;
    	private double speed;
     
    	//constructors
     public Ship()
       {
     
       }
     
    	//methods
    	public String getName()
    	{
    		return name;
    	}
     
    	public double getSpeed()
    	{
    		return speed;
    	}
     
    	public void setName(String newName)
    	{
    		name = newName;
    	}
     
    	public void setSpeed(double s)
    	{
    		if (s >= 0)
    		speed = s;
    	}
     
    	public double timeToCrossEnglishChannel(double s)
    	{
    		return speed * 2;
     
    	}
    }
    And file ShipTest
    //import java.util.Scanner;
    public class ShipTest
    {
    	public static void main(String[] args)
    	{	
    		Ship myShip = new Ship();
     
    		myShip.setName("Rob Roy");
     
    	}
    }
    So in File ship how to: Declare a public method called timeToCrossEnglishChannel.
    It takes no parameter and returns the number of hours it takes to cross the channel. The return value is of type double.
    and in File Shiptest how to: Create an instance of type Ship. Call the variable of type Ship paddleStreamer.
    The name of the paddleStreamer is Rob Roy and the speed is 6 knots. Use this information to assign the fields.
    Attached Files Attached Files
    Last edited by ristory; October 5th, 2012 at 03:49 AM. Reason: Repair


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Pl help with my class assingment

    What's Wrong With My Code?
    You forgot to use code tags.
    The indentation is incorrect.
    You did not ask a question.



    Please edit your post and use code tags on the code, and fix the indentation so it is easy to read. There are instructions on how to do so in the forum rules.

Similar Threads

  1. need to make basic class and implementation class (base class without void main)
    By javanewbie101 in forum Object Oriented Programming
    Replies: 1
    Last Post: September 19th, 2012, 08:03 PM
  2. create a test class (main method) to start(run) the class in Java
    By curious725 in forum Java Theory & Questions
    Replies: 5
    Last Post: August 1st, 2012, 03:21 AM
  3. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM
  4. Replies: 3
    Last Post: April 13th, 2011, 03:30 PM
  5. Assingment help
    By bjcdude in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 8th, 2011, 05:09 PM