posted 14 years ago
ok i managed to solve the problem thanks those who helped
but i got another problem how do retrive info i stored in an array.. from another class
Database.java
public class Database{
private String CarList[] = { "Altis", "Vios", "Latio", "Murano", "Jazz", "Civic", "Stream", "Odyssey", "WRX", "Impressa" };
public String findCarByModel(){
}
}
Car.java
public class Car{
private String regno;
private String make;
private String model;
private int deposit;
private int rate;
//public static int calculateCost(int x) {
//return int;
//}
public void setMake(String m){
m=make;
}
public String getMake(){
Database myDatabase = new Database();
return make;
}
}
mainmethod.java
import java.util.Scanner;
public class mainmethod{
public static void main(String args[]){
Car myCar = new Car();
Scanner input = new Scanner(System.in);
System.out.print("Enter the model to rent: ");
myCar.setMake(input.nextLine());
String make = myCar.getMake();
if(make == null){
System.out.print("Model not is available");
}
}
}