Untitled
unknown
plain_text
2 years ago
6.7 kB
6
Indexable
package view;
import java.util.*;
import model.Underwriter;
import model.Vehicle;
public class MVC_Main {
public static void main(String[] args) {
Underwriter u = new Underwriter();
Vehicle v = new Vehicle();
Scanner sc = new Scanner(System.in);
boolean flag = true;
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("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:
case 2:
case 3:
case 4:
case 5:
case 6:
default:
System.out.println("Wrong Input!");
}
}catch(InputMismatchException e1) {
System.out.println("Wrong Input");
}
}
case 2:
boolean fg = true;
while(fg) {
try {
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:
case 2:
case 3:
case 4:
default:
System.out.println("Wrong Input!");
}
}catch(InputMismatchException e2) {
System.out.println("Wrong Input");
}
}
default:
System.out.println("Wrong input!");
}
}catch(InputMismatchException e) {
System.out.println("Wrong input!");
}
}
sc.close();
}
}
package model;
import java.time.LocalDate;
public class Underwriter {
private int uid;
private String name;
private LocalDate dob;
private LocalDate jd;
private String pwd;
public int getId() {
return uid;
}
public void setId(int uid) {
this.uid = uid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public LocalDate getdob() {
return dob;
}
public void setdob(LocalDate dob) {
this.dob = dob;
}
public LocalDate getjd() {
return jd;
}
public void setjd(LocalDate 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 model;
import java.time.LocalDate;
public class Vehicle {
private int pno;
private String vno;
private String vtype;
private String cname;
private int engno;
private int chno;
private Long phno;
private String itype;
private int preamo;
private LocalDate fd;
private LocalDate td;
private int uid;
public int getpno() {
return pno;
}
public void setpno(int pno) {
this.pno = pno;
}
public int getId() {
return uid;
}
public void setId(int uid) {
this.uid = uid;
}
public String getvno() {
return vno;
}
public void setvno(String vno) {
this.vno = vno;
}
public String getvtype() {
return vtype;
}
public void setvtype(String vtype) {
this.vtype = vtype;
}
public String getName() {
return cname;
}
public void setName(String cname) {
this.cname = cname;
}
public int getengno() {
return engno;
}
public void setengno(int engno) {
this.engno = engno;
}
public int getchno() {
return chno;
}
public void setchno(int chno) {
this.chno = chno;
}
public Long getphno() {
return phno;
}
public void setphno(Long phno) {
this.phno = phno;
}
public String getitype() {
return itype;
}
public void setitype(String itype) {
this.itype = itype;
}
public int getpreamo() {
return preamo;
}
public void setpreamo(int preamo) {
this.preamo = preamo;
}
public LocalDate getfd() {
return fd;
}
public void setfd(LocalDate fd) {
this.fd = fd;
}
public LocalDate gettd() {
return td;
}
public void settd(LocalDate td) {
this.td = td;
}
@Override
public String toString() {
return "Vehicle [pno= " + pno + ", vno= " + vno + ", vtype= " + vtype + ", cname= " + cname + ", engno= " + engno + ", chno= " + chno + ", phno= " + phno + ", itype= " + itype + ", preamo= " + preamo + ", fd= " + fd + ", td= " + td + ", uid= " + uid + "]";
}
}
package helper;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import model.Underwriter;
import model.Vehicle;
public class PolicyHelper {
private static final String url = "jdbc:mysql://intvmunix1/DB_TVM29_2324";
private static final String user = "USER_TVM29_2324";
private static final String password = "Tcs@12345";
private static Connection conn;
public static Connection getConnection() throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url, user, password);
return conn;
}
public static void closeConnection() {
try {
if(conn != null && !conn.isClosed()) {
conn.close();
}
}catch(SQLException e) {
e.printStackTrace();
}
}
public static Underwriter mapResultSetToUnderwriter(ResultSet rs) throws SQLException {
Underwriter un = new Underwriter();
un.setuid(rs.getInt("uid"));
un.setName(rs.getString("name"));
un.setdob(rs.getDate("dob"));
un.setjd(rs.getDate("jd"));
un.setpwd(rs.getString("pwd"));
return un;
}
public static Vehicle mapResultSetToVehicle(ResultSet rss) throws SQLException {
Vehicle v = new Vehicle();
Underwriter u = new Underwriter();
v.setpno(rss.getInt("pno"));
v.setvno(rss.getString("vno"));
v.setvtype(rss.getString("vtype"));
v.setname(rss.getString("cname"));
v.setengno(rss.getInt("engno"));
v.setchno(rss.getInt("chno"));
v.setphno(rss.getLong("phno"));
v.setitype(rss.getString("itype"));
v.setpreamo(rss.getInt("preamo"));
v.setfd(rss.getDate("fd"));
v.settd(rss.getDate("td"));
v.setid(rss.getInt("uid"));
return v;
}
}Editor is loading...
Leave a Comment