id
stringlengths
36
36
text
stringlengths
1
1.25M
f71caa68-3ac6-42e2-91e4-1a01a3a05caa
public Card(){ color = 0; card = 0; }
4c7983f7-0dac-425d-9844-d3076b210052
public Card(char color, char card) throws Exception { color = Character.toUpperCase(color); card = Character.toUpperCase(card); if(color != 'H' && color != 'D' && color != 'S' && color != 'C'){ throw new Exception("Bad color"); } this.color = color; if((card < '2' || card > '9') && card != 'T' &&...
bd3dee1a-dbb6-401c-8eb4-a20b85037fb1
public Character getCard(){ return card; }
bbd325c4-8b78-424e-be7c-d15f5b16f7d2
public int getCardValue() { Character[] arr = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'}; for (int i = 0 ; i < 13 ; i ++) { if (card == arr[i]) return i; } return -1; }
b88fc7f5-4cc7-4d07-8d7a-132781b41cb0
public Character getColor() { return color; }
6396c834-a379-4cce-aa5d-c2eb9817a15c
public int getColorValue() { switch(color){ case 'S': return 3; case 'H': return 2; case 'D': return 1; case 'C': return 0; } return -1; }
50b049ab-4028-46b0-b971-f3e0553705e1
public String toString(){ return ""+color+card; }
09f0a3cf-c8dd-4a86-bb7e-0ff740d3fd49
@Override public int compareTo(Card c) { /*if(c.getCardValue() == this.getCardValue()){ return this.getColorValue() - c.getColorValue(); }*/ return this.getCardValue() - c.getCardValue(); }
abefcb9c-8dde-41c6-a0c2-996c4d62c464
public Messenger(Object arg) { listener = arg; msg = ""; Method getInput = null; Method getOutput = null; //Initialize input/output try { listenerAdapter = Class.forName(listener.getClass().getName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { getInput = listener...
8b37874d-f8c0-47fc-b12a-5fcd83335617
public void receive() { while(msg != null) { try { msg = in.readLine(); } catch (IOException e) { //e.printStackTrace(); performMethod("finalize"); break; } //if (!msg.equals("")) System.out.println(" { DEBUG: "+msg+"}"); // DEBUG if ("END".equals(msg)) { Class cl = listener...
f12444b2-5a77-4b7d-8c54-27e88d03c134
public void broadcast(String msg) { out.println(msg); }
176d117b-d97f-4c2f-91fb-77cf59bc8216
public void performMethod(String name, Object... params) { Method m = null; try { m = listenerAdapter.getMethod(name, new Class[]{String.class}); } catch (NoSuchMethodException | SecurityException e) { try { m = listenerAdapter.getMethod(name); } catch (NoSuchMethodException | SecurityException e1) {...
ebd4e6cf-b681-4a66-8495-4f539f04858c
private int getID() { Method m = null; int id = -1; try { m = listenerAdapter.getMethod("getID"); } catch (NoSuchMethodException | SecurityException e) { e.printStackTrace(); } try { id = (int) m.invoke(listener); } catch (IllegalAccessException | IllegalArgumentException | InvocationTarge...
cf04797a-9fbb-45e2-a1cf-b99220235e57
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { List<Department> departments = new ArrayList<>(); List<Position> positions = new ArrayList<>(); DepartmentDBManager departmentDBManager = new DepartmentDBManager(); ...
da4dceb2-ca90-47d2-b93c-ab823236105c
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String name =""; String birthday = ""; String passportNumber = ""; int department = 0; int position = 0; BigDecimal salary = null; if (re...
d5020501-b92a-4c36-b9a4-63f82a7d1b87
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { List<Department> departmentList = new ArrayList<>(); DepartmentDBManager departmentDBManager = new DepartmentDBManager(); try { departmentList = departmentDBM...
04bf6b5d-b3f0-45e9-9a46-b1a1b24be3bd
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { BigDecimal minSalary = null; BigDecimal maxSalary = null; String name = ""; int department = 0; if (req.getParameter("name") != null) { name ...
6edce6f5-db37-44fe-acb6-195b2d2ffc9c
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (req.getParameterMap().containsKey("dep")){ showSelectedDepartment(req, resp); } else { showDefaultPage(req, resp); } }
d1e41799-48b0-45c1-94ac-6168ed14253c
private void showDefaultPage(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { List<Department> departments = new ArrayList<>(); Department department = new Department(); DepartmentDBManager departmentDBManager = new DepartmentDBManager(); try ...
c458b25d-e84d-4854-9512-7cb869b66949
private void showSelectedDepartment(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String depParam = req.getParameter("dep"); int departmentId = Integer.parseInt(depParam); List<Employee> employees = new ArrayList<>(); List<Department> departme...
136025f7-0439-436a-b416-50c7040ec5d2
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req,resp); }
188aa439-3d32-4439-8457-f8fd6b98d0a8
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int id = 0; try { id = Integer.parseInt(req.getParameter("id")); }catch (NumberFormatException e){ e.printStackTrace(); } Departmen...
ac69ebc4-1e72-47d5-953a-caac65c94946
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { mainForward(req, resp); }
55dc97eb-5b03-432c-8e37-4bbcec05fcfe
private void mainForward(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { List<Department> departments = new ArrayList<>(); DepartmentDBManager departmentDBManager = new DepartmentDBManager(); try { departments = departmentDBManager.getAllDep...
a03159f3-f079-428d-8593-b671e36f17be
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String departmentName = req.getParameter("name").trim(); if (!departmentName.equals("")) { DepartmentDBManager departmentDBManager = new DepartmentDBManager(); ...
66bfe12e-f194-48fc-b248-c9d3ae8144ca
private void warningForward(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String warning = "Please write correct department!"; req.setAttribute("warning", warning); mainForward(req, resp); }
3726e1b2-89fb-4159-b5cf-d5117db3b9f7
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int userId =0; try { userId = Integer.parseInt(req.getParameter("id")); } catch (NumberFormatException e) { e.printStackTrace(); } ...
dbe5d1f0-0efd-48c3-9e89-b55ae3060ced
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int id = 0; try { id = Integer.parseInt(req.getParameter("id")); }catch (NumberFormatException e){ e.printStackTrace(); } int dep...
4ae36f22-241b-4eb2-952a-6d590c8aae36
public void setId(int id) { this.id = id; }
8fdce2a1-c514-41de-a94b-74ebb626ba89
public String getName() { return name; }
6699780f-dc52-4667-b97b-b8343b68ece0
public void setName(String name) { this.name = name; }
2e924059-610b-488a-9149-7b7f8bd27f0a
public int getId() { return id; }
dbfb12b3-2933-4183-bd8f-ffcf5ddbae25
public Department() { }
ac5948b8-b1b5-4586-8206-41e969ae9838
public Department(String name) { this.name = name; }
d26d45bd-764c-4019-8396-9a6009346f5e
public Department(int id, String name) { this.id = id; this.name = name; }
15a077db-c87e-44dc-a2fd-2cf58f68cf7f
@Override public String toString() { return "Department{" + "id=" + id + ", name='" + name + '\'' + '}'; }
9d3919f6-15db-449b-b9d3-86366f0c3b9d
public BigDecimal getSalary() { return salary; }
4780ce15-6730-423e-a927-5b4252ad1034
public void setId(int id) { this.id = id; }
c8a8e104-1261-4002-abea-6318b0c75226
public void setSalary(BigDecimal salary) { this.salary = salary; }
5f0968ae-b4f3-4b9b-8199-73b5a81a86ff
public int getId() { return id; }
472b59de-f69f-4f43-89a8-d26c9d78fff3
public String getName() { return name; }
734937ee-48ee-44bd-81dd-031ab0ea8749
public void setName(String name) { this.name = name; }
2700c6af-5ada-4c4f-be8c-cdff46d54eab
public Date getBirthday() { return birthday; }
6ca2143d-21b5-414b-925d-b1a5b8fb9370
public void setBirthday(Date birthday) { this.birthday = birthday; }
f13b9910-d0b8-430a-94bf-e54fad24fd8e
public String getPassportNumber() { return passportNumber; }
d6dd3322-8453-48fd-832e-3ad80aab46f7
public void setPassportNumber(String passportNumber) { this.passportNumber = passportNumber; }
ba4137f6-3001-4879-86d8-8948d30c000f
public Department getDepartment() { return department; }
624f2e1b-2bf6-406a-9eb2-5fc7380e4ae8
public void setDepartment(Department department) { this.department = department; }
5650af4c-c690-4526-9d94-4c9714b29292
public Position getPosition() { return position; }
f864a373-c5f2-46bf-bbac-dacf3aeb2c51
public void setPosition(Position position) { this.position = position; }
74bb09d5-4890-4831-919e-8226807a8d8c
@Override public String toString() { return "Employee{" + "id=" + id + ", name='" + name + '\'' + ", birthday=" + birthday + ", passportNumber='" + passportNumber + '\'' + ", department=" + department + ", positi...
7a18668a-3d8f-4daa-95e5-1975f35607cd
public int getDepartment() { return department; }
82e854e1-28dd-40fa-9743-e0249995299a
public void setDepartment(int department) { this.department = department; }
182f4f1b-ab2e-4717-8113-b64c64df969f
public int getId() { return id; }
320e4327-7cd8-491e-8118-5744a865bdad
public String getName() { return name; }
a0590306-84b8-4a92-aac4-e808d6c6a503
public void setName(String name) { this.name = name; }
4cbb5d2f-d293-4783-9da8-adc998fd401f
public BigDecimal getMinSalary() { return minSalary; }
948f3f75-ebc3-4fb0-97e5-49ad8dfa3383
public void setMinSalary(BigDecimal minSalary) { this.minSalary = minSalary; }
517f29d8-8c00-463e-99f7-880cb19b1e9b
public BigDecimal getMaxSalary() { return maxSalary; }
66399480-4201-4da2-a11c-486ee3f24d64
public void setMaxSalary(BigDecimal maxSalary) { this.maxSalary = maxSalary; }
484c05c6-9a14-4aaa-b238-5acaa92dd45f
public Position() { }
4fce2538-ac50-4470-894d-0f1295284b01
public Position(String name, BigDecimal minSalary, BigDecimal maxSalary) { this.name = name; this.minSalary = minSalary; this.maxSalary = maxSalary; }
618f35b7-97eb-4d42-a3a7-c8f06d9caf9c
public Position(int id, String name, BigDecimal minSalary, BigDecimal maxSalary) { this.id = id; this.name = name; this.minSalary = minSalary; this.maxSalary = maxSalary; }
dbeff2fe-8b6e-457a-ac8c-c05b96956fef
public void setId(int id) { this.id = id; }
1dd37f90-a2a5-4b44-a11a-6df157d97ea3
@Override public String toString() { return "Position{" + "id=" + id + ", name='" + name + '\'' + ", minSalary=" + minSalary + ", maxSalary=" + maxSalary + ", department=" + department + '}'; }
d5855f93-b4e9-497d-b643-b46d31d7ffd5
@Override public void init(FilterConfig filterConfig) throws ServletException { encoding = filterConfig.getInitParameter(ENCODING_INIT_PARAM_NAME); if (encoding == null) encoding = ENCODING_DEFAULT; }
94cf8a1f-61f3-42e4-9bc2-845b54e34bda
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { servletRequest.setCharacterEncoding(encoding); filterChain.doFilter(servletRequest, servletResponse); }
9d0b7f32-6e19-4633-8efe-34a170ad7154
@Override public void destroy() { }
4f4c380e-69e4-4ac1-8414-4121fd71753d
public DepartmentDBManager() { try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); System.exit(1); } }
b09fb065-148e-4d19-97f6-e7c1452ea443
private Connection getConnection() throws SQLException { // return DriverManager.getConnection("jdbc:mysql://localhost/personnel_department", "root", "shtil27101988"); //DriverManager.getConnection("jdbc:mysql:///dbname?useUnicode=true&characterEncoding=utf-8", "user", "pass"); Properties propert...
5f85f737-e233-4e68-af9d-115cccaddc49
public List<Position> getAllPositions() throws SQLException { List<Position> positions = new ArrayList<>(); try (Connection c = getConnection(); Statement st = c.createStatement() ) { ResultSet resultSet = st .executeQuery("SELECT * FROM position"); ...
3c7f32e9-3745-43b9-898e-25e15e96470a
public List<Department> getAllDepartments() throws SQLException { List<Department> departments = new ArrayList<>(); try (Connection c = getConnection(); Statement st = c.createStatement() ) { ResultSet resultSet = st .executeQuery("SELECT * FROM depa...
2cde2ab8-5587-47e7-b8a1-b0d9e889126e
public void saveNewDepartment(String name) throws SQLException { try (Connection c = getConnection(); Statement st = c.createStatement() ) { PreparedStatement stmt = c.prepareStatement( "INSERT INTO department (name) VALUES (?)"); stmt.setString(1, name); ...
727498e3-a980-4b3a-a4e7-e7938debc5f1
public void updateUser(Employee employee) throws SQLException { try (Connection c = getConnection(); PreparedStatement stmt = c.prepareStatement( "UPDATE employee SET department_id = (?), position_id = (?), salary = (?) WHERE id= (?)"); ) { stmt.setInt(1, employee.getDepartment...
6485d85e-a1ae-49ca-8e6f-575274776aea
public void saveNewUser(Employee employee) throws SQLException { try (Connection c = getConnection(); PreparedStatement stmt = c.prepareStatement( "INSERT INTO employee (name, birthday, passportNumber,department_id, position_id, salary) VALUES (?,?,?,?,?,?)"); ) { stmt.setStrin...
8f543b94-4e9c-4aed-bc0e-be76fdf5c8f9
public void saveNewPosition(Position position) throws SQLException{ try (Connection c = getConnection(); PreparedStatement stmt = c.prepareStatement( "INSERT INTO position (name,department,minSalary,maxSalary ) VALUES (?,?,?,?)"); ) { stmt.setString(1,position.getName()); ...
801d5347-ce27-4f1e-a74f-64f93a4720e0
public Department getDepartment(int departmentId) throws SQLException { Department department = new Department(); try (Connection c = getConnection(); Statement st = c.createStatement() ) { ResultSet resultSet = st .executeQuery("SELECT * FROM depart...
d9793e07-5aee-4cc7-acc4-43f3116a2a7b
public Position getPosition(int positionId) throws SQLException { Position position = new Position(); try (Connection c = getConnection(); Statement st = c.createStatement() ) { ResultSet resultSet = st .executeQuery("SELECT * FROM position WHERE id ...
ac115296-4ab3-4bd3-9d67-07f4ca02b231
public List<Employee> getAllEmployee(int departmentID) throws SQLException { List<Employee> employees = new ArrayList<>(); try (Connection c = getConnection(); Statement st = c.createStatement() ) { ResultSet resultSet = st .executeQuery("SELECT e.id...
25962b57-256d-4dca-9c57-2d244510e9d3
public Employee getEmployee(int employeeId) throws SQLException { Employee employee = new Employee(); try (Connection c = getConnection(); Statement st = c.createStatement() ) { ResultSet resultSet = st .executeQuery("SELECT e.id, e.name, e.birthday,...
19fd8fe8-a230-4062-a11d-e5dd0e952914
public void removeEmployee(int id) throws SQLException{ String sql = "DELETE FROM employee WHERE id = ?"; try (Connection c = getConnection(); PreparedStatement stmt = c.prepareStatement(sql); ) { stmt.setInt(1, id); stmt.execute(); } }
76b55547-5d1b-470a-bbc6-a0beba6f8f07
private void close() { /* close(resultSet); close(statement); close(connect); */ }
86836be7-3080-4ab4-b366-0f62cd4eb9fd
private void close(Closeable c) { try { if (c != null) { c.close(); } } catch (Exception e) { // don't throw now as it might leave following closables in undefined state } }
edef46cd-1a4c-40c3-9fb8-641237a96b07
public DBManager() { try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); System.exit(1); } }
d3a6ce53-a2f0-4b43-8658-a1764ad157b0
public List<Department> getAllDepartments () throws SQLException { List<Department> result = new ArrayList<>(); try (Connection c = getConnection(); Statement st = c.createStatement() ){ ResultSet rs = st.executeQuery("select id, name from department"...
69132ba8-ea1b-41a2-96c3-130938b6a57f
private Connection getConnection() throws SQLException { try { Context initialContext = new InitialContext(); DataSource datasource = (DataSource) initialContext.lookup("java:comp/env/jdbc/TestDB"); if (datasource != null) { return datasou...
83323494-4234-4d8e-a3fd-c38874fc387f
public static String getParkLotLabel(String number, int space, int empty, int tabs){ return getTabs(tabs)+PARKLOT_LABEL+NUMBER_LABEL+number+"\n"+ getTabs(tabs)+"\t"+SPACE_LABEL+space+"\n"+ getTabs(tabs)+"\t"+EMPTY_LABEL+empty+"\n"; }
e9ee1864-9e19-4a6c-971b-cf1cb1ca9111
public static String getStatLabel(int space, int empty, int tabs){ return getTabs(tabs)+TOTAL_LABEL+SPACE_LABEL+space+"\n"+ getTabs(tabs)+TOTAL_LABEL+EMPTY_LABEL+empty+"\n"; }
d2754bce-6a8f-4d9d-9225-086303fbe623
public static String getTabs(int tabs){//返回若干个tab键。 String str = ""; for(int i=0;i<tabs;i++){ str += "\t"; } return str; }
57208b4a-45bf-42e6-b474-ca9a7987a407
public static String getParkBoyLabel(String number, int tabs) { return getTabs(tabs)+PARKBOY_LABEL+NUMBER_LABEL+number+"\n"; }
dd50f0c0-355d-4234-9fba-6ad0a0909ff8
public Ticket push(Car car);
b3fa6d4a-4943-4705-992d-a5cbeafbb800
public Car pull(Ticket ticket);
5188d1e9-8c30-4003-9b74-5940966e43fa
public String printInfo();
e4feffc4-6940-41ed-a779-2e32bf6345cd
public ParkLot choose(List<ParkLot> parkLots);
cc359e11-66b2-41e5-b028-345e951699fd
@Override public ParkLot choose(List<ParkLot> parkLots) throws NoSpaceInBoyException { for(ParkLot p : parkLots){ if(p.getAvailableSpace()>0){ return p; } } throw new NoSpaceInBoyException(); }
2ab407fb-80bb-4647-88de-3f570d0c2ad4
public ParkManager(ParkLotChooser parkLotChooser, List<ParkLot> parkLots, String number, List<ParkingBoy> parkBoys) { super(parkLotChooser, parkLots, number); this.setParkBoys(parkBoys); }
d1aa2176-3d38-4a11-97e4-9c9951732157
public List<ParkingBoy> getParkBoys() { return parkBoys; }
3c602022-4540-492e-b07a-05ae787bb4c2
public void setParkBoys(List<ParkingBoy> parkBoys) { this.parkBoys = parkBoys; }
f5484d64-f7de-4e28-9f05-6290a27bb0d5
@Override public Ticket push(Car car) throws NoSpaceForCarException { Ticket ticket = null; for(ParkingBoy pb : this.getParkBoys()){ try{ ticket = pb.push(car); return ticket; }catch (NoSpaceInBoyException e){ } } try{ ...
5802017d-72df-4146-8385-7b77a638de9a
@Override public Car pull(Ticket ticket) throws NoCarForTicketException { Car car = null; for(ParkingBoy pb : this.getParkBoys()){ try{ car = pb.pull(ticket); return car; }catch (NoCarInBoyException e){ } } try{ car ...