Untitled
unknown
plain_text
2 years ago
5.9 kB
9
Indexable
package model;
import java.sql.Date;
import java.time.LocalDate;
public class Underwriter {
private int uid;
private String name;
private Date dob;
private Date jd;
private String pwd;
public int getuid() {
return uid;
}
public void setuid(int uid) {
this.uid = uid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getdob() {
return dob;
}
public void setdob(Date dob) {
this.dob = dob;
}
public Date getjd() {
return jd;
}
public void setjd(Date jd) {
this.jd = jd;
}
public String getpwd() {
return pwd;
}
public void setpwd(String pwd) {
this.pwd = pwd;
}
@Override
public String toString() {
return "Underwriter [id= " + uid + ", name= " + name + ", dob= " + dob + ", jd= " + jd + ", password= " + pwd + "]";
}
}
package view;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.sql.Date;
import controller.PolicyController;
import model.Admin;
import model.Underwriter;
import model.Vehicle;
public class MVC_Main {
public static void main(String[] args) throws ParseException, ClassNotFoundException {
Underwriter u = new Underwriter();
Vehicle v = new Vehicle();
Admin m = new Admin();
PolicyController pc = new PolicyController();
Scanner sc = new Scanner(System.in);
boolean flag = true;
System.out.println("Star Protect Vehicle Insurance");
while(flag) {
try {
System.out.println("Input 1 for Admin");
System.out.println("Input 2 for Underwriter");
int choice = sc.nextInt();
switch(choice) {
case 1:
boolean f = true;
while(f) {
try {
System.out.println("Enter your id :"); int aid = sc.nextInt();
System.out.println("Enter your password :"); sc.nextLine(); String pwd = sc.nextLine();
if(aid == m.getaid() && m.getpwd().equalsIgnoreCase(pwd)) {
System.out.println("Welcome back!");
}
else {
System.out.println("Wrong credentials!");
break;
}
System.out.println("Input 1 for Underwriter Reg");
System.out.println("Input 2 to search Underwriter by ID");
System.out.println("Input 3 to update underwriter password");
System.out.println("Input 4 to delete underwriter by ID");
System.out.println("Input 5 to view all underwriters");
System.out.println("Input 6 to view all vehicle specific by underwriter ID");
int ch = sc.nextInt();
switch(ch) {
case 1:
System.out.println("UID: "); int uid = sc.nextInt(); sc.nextLine();
System.out.println("Name: "); String name = sc.nextLine();
System.out.println("DOB: "); String sdob = sc.next(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date dob = (Date) sdf.parse(sdob);
System.out.println("JD: "); String sjd = sc.next(); SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd"); Date jd = (Date) sdf.parse(sjd);
System.out.println("PWD: "); String pswd = sc.nextLine();
pc.addUnderwriter(uid, name, dob, jd, pwd);
break;
case 2:
System.out.println("UID: "); int uids = sc.nextInt(); sc.nextLine();
pc.searchUnderwriter(uids);
break;
case 3:
System.out.println("UID: "); int uidu = sc.nextInt(); sc.nextLine();
System.out.println("New PWD: "); String pwdu = sc.nextLine();
pc.updateUnderwriterPassword(uidu, pwdu);
break;
case 4:
break;
case 5:
break;
case 6:
break;
default:
System.out.println("Wrong Input!");
}
}catch(InputMismatchException e1) {
System.out.println("Wrong Input");
}
}
break;
case 2:
boolean fg = true;
while(fg) {
try {
System.out.println("Enter your id :"); int uid = sc.nextInt();
System.out.println("Enter your password :"); sc.nextLine(); String pswd = sc.nextLine();
if(uid == m.getaid() && m.getpwd().equalsIgnoreCase(pswd)) {
System.out.println("Welcome back!");
}
else {
System.out.println("Wrong credentials!");
break;
}
System.out.println("Input 1 to create new vehicle insurance");
System.out.println("Input 2 to renew policy");
System.out.println("Input 3 to change policy type");
System.out.println("Input 4 to view policy");
int c = sc.nextInt();
switch(c) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
default:
System.out.println("Wrong Input!");
}
}catch(InputMismatchException e2) {
System.out.println("Wrong Input");
}
}
break;
default:
System.out.println("Wrong input!");
}
}catch(InputMismatchException e) {
System.out.println("Try Again!");
}
}
sc.close();
}
}
package controller;
import java.sql.Date;
import dao.PolicyDAO;
import model.Underwriter;
public class PolicyController {
private PolicyDAO pdao = new PolicyDAO();
public void addUnderwriter(int uid, String uname, Date udob, Date ujd, String upwd) throws ClassNotFoundException {
Underwriter und = new Underwriter();
und.setuid(uid);
und.setName(uname);
und.setdob(udob);
und.setjd(ujd);
und.setpwd(upwd);
}
public void searchUnderwriter(int uids) {
try {
pdao.search(uids);
}catch(ClassNotFoundException e) {
e.printStackTrace();
}
}
public void updateUnderwriterPassword(int uidu, String pwdu) {
try {
Underwriter und = new Underwriter();
und.setuid(uidu);
und.setpwd(pwdu);
pdao.update(und);
}catch(ClassNotFoundException e) {
e.printStackTrace();
}
}
}Editor is loading...
Leave a Comment