Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

what am I doing wrong? help please  RSS feed

 
ruth angel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, how are you guys? I need some help on this. I am trying to put two classes together but something is wrong I cant figure out how to fix it. Somebody can help me please? Thank you so much

I have these two classes Customer with some informaton such as companyName,contact name, customer ID and address. Ans another one is ShippingLabel with the following String custInfo = "Toys'R'Us;Lionel Giraffe;12345;101 Toy Lane, Boulder, Colorado 80301";


//set up a customer and print a shipping label.

class Customer{
private String companyName;
private String customerContactName;
private String customerID;
private String address;

//default customer
Customer()
{
companyName= "Knows Toys";
customerContactName = "Lester Jones";
customerID = "000";
address = "(Internal Shipment) Chicago, Illinois";
}
//.......................
Customer(String company, String person, String id, String location)
{
companyName= company.trim();
customerContactName = person.trim();
customerID = id.trim();
address = location.trim();
}

class shippingLabel{


public String createShippingLabel()
{
String label = "\n" + companyName + " (Customer Order Number: " + customerID +
")\n" + customerContactName + "\n" + address;
return label;
}

}
// driver for this application

public static void main(String args[])
{
// Shipping label
Customer first = new Customer(String Know Toys, String Lester Jones, String 000, String (Internal Shipment) Chicago, Illinois);
System.out.println(first.createShippingLabel());


Customer tester = new Customer();
tester.display();

//call on the display method
System.exit(0);
}


class public Customer {

public static void main(String args[]) {
// Shipping lable
String custInfo = "Toys'R'Us;Lionel Giraffe;12345;101 Toy Lane, Boulder, Colorado 80301";
String[] array = custInfo.split(";");
Customer first = new Customer(array[0], array[1], array[2], array[3]);
System.out.println(first.createShippingLabel());


ShippingLabel tester = new ShippingLabel());
tester.display();

//call on the display method
System.exit(0);
}
}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> but something is wrong

please elaborate - what is supposed to happen, and what actually happens
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, how are you guys? I need some help on this. I am trying to put two classes together but something is wrong I cant figure out how to fix it. Somebody can help me please? Thank you so much


From a quick glance, it is unlikely that this code will even compile -- unless you did an incorrect cut-n-paste to here.

The best way to deal with compile errors is to look at the first few errors. Check out the location (file and line number). And start there. It is best to fix only one or two, and then recompile again, as one may be causing another.

Generally, the error message is pretty self explanatory. Some are obscure. But with enough practice, they will all make sense. How about you paste the first few compile errors here, and we'll give you a hint in the right direction?

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!