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

Thread: Can someone see whats wrong with my code, please?

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

    Default Can someone see whats wrong with my code, please?

    Here it is;

    public class Car {


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

    public Car() {
    this.make = "Nissan";
    this.model = "Sivia";
    this.year = 1992;
    }
    public Car( String make,
    String model,
    int year ) {
    this.make = make;
    this.model = model;
    this.year = year;
    }
    public Car( String make ) {
    this.make = "Toyota";
    this.model = "Supra";
    this.year = 1996;
    }
    public String getMake() {
    return this.make;
    }
    public String getModel() {
    return this.model;
    }
    public int getYear() {

    }
    public void setMake(String make) {
    this.make = make;
    }
    public void setModel(String model) {
    this.model = model;
    }
    public void setYear( int year ) {
    this.year = year;
    }


    public String toString() {
    String out = "This is a Car. ";
    out += "Its make is " + this.make + ". ";
    out += "Its model is " + this.model + ". ";
    out += "Its year is " + this.year + ".";
    return out;
    }


    public String carTester(String make) {
    Car theCar = new Car(make);
    this.make = Car;
    this.model = Car;

    this.year = Car;
    return theCar.toString();

    }

    public static void main( String[] args) {
    System.out.println(carTester);
    }





    I'd like it to print out the make model and year, ( 1992 nissan silvia )

    PLEASE HELP ME!!!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,301
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Can someone see whats wrong with my code, please?

    Please see the link in my signature entitled 'getting help'.

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

    DJBENZ10 (July 13th, 2012)

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

    Default Re: Can someone see whats wrong with my code, please?

     
    public class Car
    {
    private String make;
    private String model;
    private int year;
     
    public Car() {
    this.make = "Nissan";
    this.model = "Sivia";
    this.year = 1992;
    }
    public Car( String make, String model, int year ) {
    this.make = make;
    this.model = model;
    this.year = year;
    }
     
    public String getMake() {
    return this.make;
    }
    public String 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 setYear( int year ) {
    this.year = year;
    }
     
     
    public String toString() {
    String out = "This is a Car.\n";
    out += "Its make is " + this.make + ".\n";
    out += "Its model is " + this.model + ".\n";
    out += "Its year is " + this.year + ".\n";
    return out;
    }
     
     
    //dont understand this crap
    //why are you even using this class
    /*public String carTester(String make) {
    Car theCar = new Car(make);
    this.make = Car;
    this.model = Car;
     
    this.year = Car;
    return theCar.toString();
    }
     
    */
     
    public static void main( String[] args) {
    Car mycar = new Car();
    System.out.println(mycar);
     
    }
    }

  5. The Following User Says Thank You to kindk12 For This Useful Post:

    DJBENZ10 (July 13th, 2012)

Similar Threads

  1. Whats wrong with my code??
    By mozza in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 14th, 2012, 10:37 AM
  2. Whats wrong with my code!!
    By nitwit3 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 22nd, 2011, 11:45 AM
  3. Whats Wrong with this code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2011, 09:59 PM
  4. Whats wrong with my code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 4th, 2011, 04:34 PM
  5. Whats wrong with my code?
    By mlan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 27th, 2010, 12:42 PM