Code error

I can't figure this one out and I'm new to Java programming and it reads:

public class MyCoffee

{

// creates a new Coffee instance

private String MyBrand;

private String MyStrength;

private double MyPrice;

// private double MyPrice;

// private String SetMyStrength;

// private String SetMyBrand;

public MyCoffee (String MyBrand, String Strength, double MyPrice){

SetMyBrand = MyBrand; // initializes MyBrand

SetMyStrength = MyStrength; // initializes MyStrength

double MyPrice = MyPrice; // initialized MyPrice

}

// constructor initializes MyBrand with String supplied as argument

public MyCoffee( String name )

{

MyBrand = Brand; // initializes MyBrand

MyStrength = Strenght; // initializes MyStrength

double MyPrice = MyPrice; // initializes MyPrice

} // end constructor

// method to set the variables

public void setMyCoffee( String MyBrand )

{

setMyBrand = MyBrand; // stores MyBrand

setMyStrength = MyStrength; //stores MyStrength

setMyPrice = MyPrice;

} // end method setMyCoffee

// method to retrieve MyCoffee

public String getMyBrand()

{

return MyBrand();

return MyStrength();

return double MyPrice()

} // end method getMyBrand

// display a welcome message to the MyCoffee user

public void displayGetMethod()

{

// calls for getMyBrand to get the

// name of MyCoffee

getMyBrand();

getMyStrength();

getMyPrice();

}

// constructor should initialize the call

public static void main(String arg[])

{

coffee.setBrand(Starbucks);

coffee.setPrice(1.0);

Coffee coffee = new Coffee ("Starbucks", "Strong", 10.00);

System.out.println("Select from these Choices");

System.out.println(MyBrand + coffee.getMyBrand());

System.out.println(MyStrength, + coffee.getStrength());

System.out.println(MyPrice, + coffee.getMyPrice());

// end display Getmethod

}

} // end class MyCoffee

[2138 byte] By [palmerka] at [2007-11-27 2:24:53]
# 1
Put your code in code tags. When posting code look at the top of the posting screen and select all of the code that you are posting then hit the code button.~Kaeloc
Kaeloca at 2007-7-12 2:32:29 > top of Java-index,Java Essentials,New To Java...
# 2
You can best also give the error because it's easier to help with the errorSatanduvel
Satanduvela at 2007-7-12 2:32:29 > top of Java-index,Java Essentials,New To Java...
# 3

> I can't figure this one out and I'm new to Java

> programming and it reads:

>

No it doesn't, and it can't write either! ;-)

Now back to the post.

As mentioned by the previous two posters, post the entire error message you are getting, and repost your code, but this time, before you post your code, push the "code" button above the window in which you type, and copy the in between the two tags that show up as a result.

masijade.a at 2007-7-12 2:32:29 > top of Java-index,Java Essentials,New To Java...
# 4

public MyCoffee (String MyBrand, String Strength, double MyPrice){

SetMyBrand = MyBrand; // initializes MyBrand

SetMyStrength = MyStrength; // initializes MyStrength

double MyPrice = MyPrice; // initialized MyPrice

}

here plz use the "this" operator to make things clearer, also note that SetMyBrand & SetMyStrength variables haven't been created .

// constructor initializes MyBrand with String supplied as argument

public MyCoffee( String name )

{

MyBrand = Brand; // initializes MyBrand

MyStrength = Strenght; // initializes MyStrength

double MyPrice = MyPrice; // initializes MyPrice

} // end constructor

where are the Brand,Strength variables created?

// method to retrieve MyCoffee

public String getMyBrand()

{

return MyBrand();

return MyStrength();

return double MyPrice()

} // end method getMyBrand

// display a welcome message to the MyCoffee user

public void displayGetMethod()

{

// calls for getMyBrand to get the

// name of MyCoffee

getMyBrand();

getMyStrength();

getMyPrice();

}

// constructor should initialize the call

the function definitions for these are missing

public static void main(String arg[])

{

coffee.setBrand(Starbucks);

coffee.setPrice(1.0);

Coffee coffee = new Coffee ("Starbucks", "Strong", 10.00);

shouldnt the object be created first before one can use it?

Flummoxeda at 2007-7-12 2:32:29 > top of Java-index,Java Essentials,New To Java...