Java Case Study VehcileIns Code
Java Case Study VehcileIns Code
Java Case Study VehcileIns Code
ArrayList;
import java.util.Date;
import java.util.Scanner;
switch (roleChoice) {
case 1:
adminLogin();
break;
case 2:
underwriterLogin();
break;
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
if (admin.validateAdmin(userId, password)) {
adminMenu();
} else {
System.out.println("Invalid credentials. Please try again.");
}
}
switch (adminChoice) {
case 1:
admin.registerUnderwriter();
break;
case 2:
admin.searchUnderwriter();
break;
case 3:
admin.updateUnderwriterPassword();
break;
case 4:
admin.deleteUnderwriter();
break;
case 5:
admin.viewAllUnderwriters();
break;
case 6:
admin.viewVehiclesByUnderwriterId();
break;
case 7:
exit = true;
break;
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
class Admin {
private String adminUserId;
private String adminPassword;
class Underwriter {
int id;
String name;
String dob;
String joiningDate;
String password;
ArrayList<VehicleInsurance> vehicles = new ArrayList<>();
public Underwriter(int id, String name, String dob, String joiningDate, String
password) {
this.id = id;
this.name = name;
this.dob = dob;
this.joiningDate = joiningDate;
this.password = password;
}
@Override
public String toString() {
return "Underwriter ID: " + id + ", Name: " + name + ", DOB: " + dob + ",
Joining Date: " + joiningDate;
}
}
class VehicleInsurance {
int policyId;
String vehicleNumber;
String vehicleType;
String customerName;
int engineNumber;
int chassisNumber;
long phoneNumber;
String insuranceType;
double premiumAmount;
Date fromDate;
Date toDate;
@Override
public String toString() {
return "Policy ID: " + policyId + ", Vehicle No: " + vehicleNumber + ",
Type: " + vehicleType +
", Customer: " + customerName + ", Premium: " + premiumAmount + ",
Validity: " + fromDate + " to "
+ toDate;
}
}