• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is the problem here?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all. yes I see now my problem.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic