• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is the problem here?  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting crazy already with this code...

Somebody can help me here? What is wrong at this time?

public class Customer
{
private String CompanyName = "Know Toys";
private String CustomerContactName = "Lester Jones";
private String CustomerID = "000";
private String Address = "(Internal Shipment) Chicago, Illinois";

/**
* Creates a new customer
*/
public Customer()
{
CompanyName = know Toys;
CustomerContactName = Lester Jones;
CustomerId = 000;
Address = (Internal Shipment) Chicago, Illinois;

}


public Customer(String CompanyName, String CustomerContactName, String CustomerID, String Address)
{
CompanyName = CompanyName;
CustomerContactName = CustomerContactName;
CustomerId = CustomerId;
Address = Address;
}

public String getCompanyName(){
return CompanyName;
}
public String getCustomerContactName(){
return CustomerContactName;
}
public String getCustomerId(){
return CustomerId;
}
public String getAddress(){
return Address;
}

public void setCompanyName(String CompanyName){
CompanyName = CompanyName;
}
public void setCustomerContactName(String CustomerContactName){
CustomerContactName = CustomerContactName;
}
public void setCustomerId(String CustomerId){
CustomerId = CustomerId;
}
public void setAddress(String Address){
Address = Address;
}
}
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ruth,

what kind of error are you getting.

My initial thoughts:

1>
CompanyName = know Toys;
CustomerContactName = Lester Jones;
CustomerId = 000;
Address = (Internal Shipment) Chicago, Illinois;

should be

CompanyName = "know Toys";
CustomerContactName = "Lester Jones";
CustomerId = "000";
Address = "(Internal Shipment) Chicago, Illinois";

2>

If you have already initialized the class variables , then why do you need to do the same thing in the default constructor.

public Customer(){} should be fine.
 
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error do you get when you compile?

1. variables' first letter is always lower case (convention), i.e. address not Address.

2.

public Customer()
{
CompanyName = know Toys;
CustomerContactName = Lester Jones;
CustomerId = 000;
Address = (Internal Shipment) Chicago, Illinois;
}

The four variables (CompanyName, CustomerContactName, ect.) are string, so they should be initialized with string values..
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Missing double quotations in Customer(), and mispelling customerID/customerId.
And you don't need to initialize the String members twice.
 
ruth angel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all. yes I see now my problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!