The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

putting class into 2 guis

Posted by Lee Morgan on January 18, 2002 at 7:11 AM

I have the class below:

import java.util.Vector;
import MisIO.*;

public class TesterOne
{
public static void main(String args[])
{

/* THIS CODE NEEDS TO BE IN A GUI */

System.out.println("type receipt number : ");
String l = BasicIO.readString();
System.out.println("type name : ");
String x = BasicIO.readString();
System.out.println("type address : ");
String y = BasicIO.readString();
System.out.println("type date : ");
String z = BasicIO.readString();
System.out.println("type amount : ");
String m = BasicIO.readString();
// create a customer
Customer firstCustomer = new Customer(l, x, y, z, m); ;


Customer.initialize();
try // test addNew
{
firstCustomer.addNew();

System.out.println("added customer");
}
catch(DuplicateException e)
{System.out.println(e);}

// test getAll
Vector allCustomers = Customer.getAll();
for(int i = 0; i < allCustomers.size(); i++)
{ // display attributes for each customer retrieved
firstCustomer = (Customer) allCustomers.elementAt(i);
System.out.println("getAll " + firstCustomer.tellAboutSelf());
}


/* THIS CODE NEEDS TO BE IN A SEPERATE GUI */

System.out.println();
System.out.println("type name to find : ");
String h = BasicIO.readString();

try // test find
{
firstCustomer = Customer.find(h);
System.out.println("find " + firstCustomer.tellAboutSelf());
}
catch(NotFoundException e)
{System.out.println(e);}

/* IGNORE CODE BELOW */

/*try // test delete
{ // delete customer
firstCustomer.delete();
System.out.println("delete " + firstCustomer.tellAboutSelf());
// try to find the customer just deleted
firstCustomer = Customer.find(d);
System.out.println("find " + firstCustomer.tellAboutSelf());
}
catch(NotFoundException e)
{System.out.println(e);} */

/*try // test update
{ // change address for customer
firstCustomer = Customer.find(h);
firstCustomer.setAddress("Coventry");
firstCustomer.update();
// display address after change
firstCustomer = Customer.find(h);
System.out.println("update " + firstCustomer.tellAboutSelf());
}
catch(NotFoundException e)
{System.out.println(e);}
*/
Customer.terminate();
}
}


This class adds some customer info to a file and then finds some info from the file using a variable inputted by the user, I need two guis one to add data and one two find it. Ive created the add gui simply by using the exact adding code in the testone class and that works fine. The problem I have is with the find code as this relies on the following statement:
Customer firstCustomer = new Customer(l, x, y, z, m);
obviously this code won't work in a seperate class due to the parameters........how can I use the find code in another class.
Any code/help would be much appreciated.Lee.



Replies:
  • 2 guis? Joker January 18, 2002 at 4:14 PM (1)
  • 2 guis? Joker January 18, 2002 at 4:14 PM (0)
  • 2 guis? Joker January 18, 2002 at 4:14 PM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us