I have the following code which is in a class called customerModel. How do I call this method to another method inside another class called customerController? I am abit new to this and have been trying for ages but have had no luck. Please help thank you.
public class customerModel{
.......
.......
public ArrayList<Customer> search(Customer cust) {
ArrayList<Customer> custs = new ArrayList<Customer>();
Connection connection = GaritsConnectivity.connect();
Tuple<ResultSet, Statement> trs = GaritsConnectivity.read("SELECT * FROM Customer WHERE Name=1", connection);
ResultSet rs = trs.getFirst();
try {
//takes a customer, returns it with the correct ID set
while (rs.next()) {
custs.add(createFromRs(rs));
}
} catch (SQLException ex) {
GaritsConnectivity.manageException("Customer search failure", ex);
}
GaritsConnectivity.doneReading(connection, trs);
return custs;
}
}
The above code is inside customerModel and below is the code I have inside customerController
package Customer;
import GUI.TestFrame;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Stack;
import javax.swing.JPanel;
public class CustomerController {
private CustomerModel cMod;
private CustomerView cView;
private TestFrame context;
//creates the view and model objects
public CustomerController(GaritsFrame context) {
this.context = context;
cView = new CustomerView(this);
context.stackPush(cView);
context.setContentPane(cView);
context.pack();
cView.disableFields();
cMod = new CustomerModel();
populateCustomerList();
public boolean deleteCusts(List<Customer> custs) {
boolean retB = true;
for(Customer cust : custs){
retB = retB && cMod.deleteSingle(cust);
}
return retB;
}
public boolean search(){
//what goes in here im lost? how can i connect the above search from customerModel to customerController?
}
public TestFrame getContext(){
return context;
}
}