StealthRT
02-15-2008, 04:22 PM
Hey all i am in need of some help figuring out how to use a set method in the problem below:
public class Test1 {
public static void main(String[] args) {
Sales s1 = new Sales("123","South",4500);
System.out.println(s1);
s1.setID("1123");
System.out.println(s1 + "\n");
System.out.println("-------------\n");
}
}
and it calls Sales by this class:
public class Sales
{
private String id;
private String Region;
private double Amount;
public Sales(String theId, String theRegion, double theAmount)
{
id = theId;
Region = theRegion;
Amount = theAmount;
}
public String getID()
{
return id;
}
public String getRegion()
{
return Region;
}
public double getAmount()
{
return Amount;
}
public String toString()
{
return "ID: " + getID() + "\n" +
"Region: " + getRegion() + "\n" +
"Amount: " + getAmount() + "\n";
}
}
Now the code works but it only gets the values of "123","South",4500 and not the s1.setID("1123"). What do i need to add to the Sales class in order to read that setID?
David
public class Test1 {
public static void main(String[] args) {
Sales s1 = new Sales("123","South",4500);
System.out.println(s1);
s1.setID("1123");
System.out.println(s1 + "\n");
System.out.println("-------------\n");
}
}
and it calls Sales by this class:
public class Sales
{
private String id;
private String Region;
private double Amount;
public Sales(String theId, String theRegion, double theAmount)
{
id = theId;
Region = theRegion;
Amount = theAmount;
}
public String getID()
{
return id;
}
public String getRegion()
{
return Region;
}
public double getAmount()
{
return Amount;
}
public String toString()
{
return "ID: " + getID() + "\n" +
"Region: " + getRegion() + "\n" +
"Amount: " + getAmount() + "\n";
}
}
Now the code works but it only gets the values of "123","South",4500 and not the s1.setID("1123"). What do i need to add to the Sales class in order to read that setID?
David