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 7 of 7

Thread: Please help!

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Please help!

    I'm so confused and I really need someone's assistance. I cant express how much I'd appreciate it.

    here is my code!

    public class Airplane {

    private String make;
    private String model;
    private int year;

    public Airplane() {
    this.make = "Boeing";
    this.model = "qtr";
    this.year = 1999;
    }

    public Airplane( String make,
    String model,
    int year ) {
    this.make = make;
    this.model = model;
    this.year = year;
    }
    public Airplane( String name) {
    this.make = make;
    this.model = model;
    this.year = 2003;
    }

    public String getMake() {
    return this.make;
    }
    public int getModel() {
    return this.model;
    }
    public int getYear() {
    return this.year;
    }
    public void setMake( String make ) {
    this.make = make;
    }
    public void setModel ( String model ) {
    this.model = model;
    }
    public void accelerat() {
    }
    public String toString() {
    String out = "This is an Airplane. ";
    out += "Its make is " + this.make + ". ";
    out += "Its model is " + this.model + ". ";
    out += "Its year is " + this.year + ".";
    return out;
    }


    public String airplaneTester(String make) {
    Airplane thePlane = new Airplane(make);
    this.make("Boeing");
    this.model("qtr");
    this.year(2005);
    return thePlane.toString();

    }


    public static void main( String[] args) {
    System.out.print.ln(thePlane);
    }


    }


    Please help me! Thanks in advance

  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Please help!

    DJBENZ10
    Your Java Program is full of ...weirdness. Here is a piece how you get a printout.
    public static void main( String[] args) {
    	Airplane ap = new Airplane();
    	ap.setMake(args[0]);
    	ap.setModel("777");
    	JOptionPane.showMessageDialog( null, ap.toString());
    }

    java Airplane Boing...then you get something funny.

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    29
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default Re: Please help!

    YOU CODE IS FULL OF CRAP
    AND YOU NEED TO LEARN JAVA AGAIN DUDE
    HERE IS WHAT CAN GIVE YOU THE OUTPUT
    ...
    Last edited by copeg; July 11th, 2012 at 10:53 PM. Reason: spoonfeeding

  4. #4
    Junior Member hackthisred's Avatar
    Join Date
    Apr 2012
    Posts
    18
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Please help!

    public class Shapes {
     
    	private int length;
    	private int width;
     
    	/**
    	 * This a constructor for an object
    	 * by which parameter are passed in at 
    	 * object's creation
    	 * @param side1
    	 */
    	public Shapes(int side1) {
    		setLength(side1);
    		setWidth(side1);
    	}
     
    	/**
    	 * This is the other constructor notice it is overloaded 
    	 * which means the compiler knows which one to utilize 
    	 * at runtime based on the number of input parameters
    	 * @param side1
    	 * @param side2
    	 */
    	public Shapes(int side1, int side2){
    		setLength(side1);
    		setWidth(side2);
    	}
     
    	public int getLength() {
    		return length;
    	}
     
    	public void setLength(int length) {
    		this.length = length;
    	}
     
     
    	public int getWidth() {
    		return width;
    	}
     
     
    	public void setWidth(int width) {
    		this.width = width;
    	}
     
     
     
    	public static void main(String[] args) {
     
    		Shapes square = new Shapes(3);
    		Shapes rectangle = new Shapes(8,2);
     
    		System.out.println("The square object has a length of " + square.getLength() +
    				"cm and a width of " + square.getWidth() + "cm\n");
     
    		System.out.println("The rectangle object has a length of " + rectangle.getLength() +
    				"cm and a width of " + rectangle.getWidth() + "cm");
     
    	}
     
    }
    f34r th3 kut3 1z

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Please help!

    I'm so confused and I really need someone's assistance. I cant express how much I'd appreciate it.
    Please read the link in my signature entitled 'Getting Help'

    @kindk12, you've received a final warning.

    @hackthisred, is there a reason for your post?

  6. The Following User Says Thank You to copeg For This Useful Post:

    DJBENZ10 (July 13th, 2012)

  7. #6
    Junior Member hackthisred's Avatar
    Join Date
    Apr 2012
    Posts
    18
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Please help!

    There is. DJBENZ10 is using all sorts of java abnormalities to accomplish a seemly simple task, I simply posted a simple example as to how one might use a simple constructor. His post was at the very least vague, I could only guess as to what help was actually needed. I took a guess the only reason one would ever write code in such a manner probably has never used constructors before; that, or they don't know the language.
    f34r th3 kut3 1z

  8. #7
    Member
    Join Date
    Jul 2012
    Posts
    71
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: Please help!

    what exactly are you trying to accomplish with this airplane class??? saying that this is vague is an understatement.....