Network 두더지 잡기 게임 2 조 9861081 신흥섭 9861009 권석진 9861012 김관수 9961201 최현식 0061060 김주호.

Slides:



Advertisements
Similar presentations
1 Android Introduction Hello Threads. 2 Goal Create an application that uses a background thread as a UDP server to receive messages from the UDP client.
Advertisements

CE203 - Application Programming Autumn 2013CE203 Part 51 Part 5.
My_Demo_Test : Air –Pollution measured at certain time points in a day t0t1t2t3t
Kerberos 그리스 신화에서 저승의 신 하데스의 문을 지키는 머리가 셋 달린 개
15-Jun-15 JDBC. JDBC is a Sun trademark It is often taken to stand for Java Database Connectivity Java is very standardized, but there are many versions.
1 JDBC: Java Database Connectivity. 2 Introduction to JDBC JDBC is used for accessing databases from Java applications Information is transferred from.
A Chat Server DBI – Representation and Management of Data on the Internet.
UFCE4Y UFCE4Y-20-3 Components and Services Julia Dawson.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
19-Aug-15 About the Chat program. 2 Constraints You can't have two programs (or two copies of the same program) listen to the same port on the same machine.
Introduction to JDBC (Java Database Connectivity).
Practical Session 11 Multi Client-Server Java NIO.
1 CSC 440 Database Management Systems JDBC This presentation uses slides and lecture notes available from
CS178 Database Management “JDBC”. What is JDBC ? JDBC stands for “Java DataBase Connectivity” The standard interface for communication between a Java.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
Concurrency in First Year Judith Bishop University of Pretoria South Africa
Views, Indexes and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Haiman Tian 1.
Dr. Magdi AMER Unit 2 Introduction to Database. Intro Many programs need to save information on disk. The role of DB system is to provide a layer of abstraction.
Cli/Serv.: Chat/121 Client/Server Distributed Systems v Objectives –discuss a client/server based chat system –mention two other ways of chatting.
Database Programming using JSP and MySQL Byung-Hyun Ha
JDBC (Java Database Connectivity) SNU OOPSLA Lab. October 2005.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Introduction to JDBC Michelle Lee, Ye Wu & Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
JDBC  The JDBC (Java Database Connectivity) API helps a Java program to access a database in a standard way  JDBC is a specification that tells the.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Index and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
이경화 Ch13. 웹 프로그래밍 설계 및 실습 MVC2 Member.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
JDBC – Java Database Concentricity
MySQL & JDCB Αλέξανδρος Καρακασίδης Δεκέμβριος 2004.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
@2010 Mihail L. Sichitiu1 Android Introduction Hello Threads.
Practical Session 11 Multi Client-Server Java NIO.
웹 프로그래밍 설계 및 실습 MVC1 Member 이경화
JDBC. Java.sql.package The java.sql package contains various interfaces and classes used by the JDBC API. This collection of interfaces and classes enable.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
모바일 자바 프로그래밍 MIDP RMS Ps lab 오민경. MIDP RMS  RMS (Record Management System)  MIDP 에서 정의하는 영속성을 지닌 자체 데이터 저장 공간  Record Store 의 집합으로 구성된 아주 간단한 데이터베이스.
16 Java Database Connectivity. 2 Understand the JDBC Understand the steps of the JDBC: 1.) Importing packages 2.) Opening a connection to a database 3.)
7장 PHP와 Mysql 연동 한빛미디어(주).
JDBC and SQLJ CIS 612 Spring JDBC JDBC is an API that enables database access from Java programs JDBC for DB access provides ◦ Portability across.
Spring 프레임워크의 이해 4. Spring AOP 이해 및 활용 Grow up to be NHN 人 Spring – AOP 요구사항 !! 비즈니스 계층과 퍼시스턴스 계층의 모든 메써드 시작과 종료시 “ 메써드 시작 ”, “ 메써드 종료 ” 라는 Logging.
Tasks Needed for MissionMapEditor Martin Q. Zhao September 18, 2010.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Basics of JDBC.
A: A: double “4” A: “34” 4.
JAVA DATABASE OOP Praktek dengan Java Miswar,S.st Sumber : Eddy Muntina Dharma,ST,MT.
Java Server Sockets ServerSocket : Object to listen for client connection requests Throws IOException accept() method to take the client connection. Returns.
Database Programming With Java & JDBC Reading: DD Ch. 18, pp al/jdbc/index.html, or anything covering JDBC.
Connection Pooling 2001/4/3 Kang Seungwoo. Connection Pooling Database Connection cost is very high Connection Pool DB 와 연결된 여러 개의 Connection 객체를 미리 확보.
방명록 제작. 목차  기본 레이아웃  DB 구조  방명록 구조  코드 설명  화면 설명.
Web Programming Assistant Professor Xiaozhong Liu
1 JDBC – Java Database Connectivity CS , Spring 2010.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
Li Tak Sing COMPS311F. Case study: a multithreaded chat server The source contains 3 files: ChatServer //the chat server ChatThread //the thread on the.
데이터 베이스 설계 및 실습 #11 - JSP 예제.
MySQL root 암호 $ mysqladmin -u root -p password new-password $ mysql -u root mysql mysql> update user set password = password('new-password') where user.
Interacting with Database
JDBC – Java Database Connectivity
Advanced Web Automation Using Selenium
HW#4 Making Simple BBS Using JDBC
Android Introduction Hello Threads.
Review Operation Bingo
Interacting with Database
Super Market Management
Using a Database with JDBC
JDBC Example.
Presentation transcript:

Network 두더지 잡기 게임 2 조 신흥섭 권석진 김관수 최현식 김주호

개발환경 및 개발 툴 개발환경 j2sdk1.4.1_01 mm.mysql bin.jar Mysql nt 개발툴 Edit plus photoshop

Server – client socket ServerSocket ClientSocket connect()accept()

서버 구조 Server Viewtext.javaInfo.javaServer.java Server 상태표시 Server 정보 Main()

서버 상태 표시 서버에서 서버의 상 태를 보여주는 창 Mysql 에 접속하여 접 속한곳을 저장하고 사용자의 아이디와 password, 점수를 불 러와 보여준다.

Server – info.java Class User Class RoomManager Class Chatter Class TextManagement Class db

TextManagement class 01 사용자 인증 02 사용자 추가 03 만들어진 방 04 접속자 명당 05 사용자정보 06 방만들기 07 선택한 방의 정보 08 채팅 메시지 전달 09 방에 들어가기 10 방에서 나가기 11 게임 시작하기

TextManagement class 소스 class TextManagement { String control = null; String realText = null; String id=null, pass=null, name=null; TextManagement(String text, int sid) { control = text.substring(0,2); realText = text.substring(3, text.length()); //System.out.print(control+" Send "); if (control.equals("01")) // 01 사용자 인증부분 { id = realText.substring(0,realText.indexOf(",",0)); pass = realText.substring(realText.indexOf(",",0)+1,realText.length()); boolean temp = User[sid].certify(id,pass); }

JDBC DriverManager Jdbc:mysql Mysql getConnection()

Db class String url = "jdbc:mysql://localho st:3306/taza"; con = DriverManager.getC onnection(url,user,p sw); Class.forName("org. gjt.mm.mysql.Driver" ); - jdbc url 을 이용하여 커넥션을 열기위해 DriverManager 의 getConnection() 메 소드를 호출한다 - Mysql 에서 mm 드라 이버를 로드한다.

DataBase 구조 Userinfo table idnamescorelastlogindatepass

Db class – 소스 부분 public String userName(String id) { String te=""; try { stmt = con.createStatement(); result = stmt.executeQuery("Select name from userinfo Where id='"+id+"'"); if(result.next()) te = result.getString(1); stmt.close(); }catch(Exception e) {System.out.println(e.toString());} return te; }

Client AccountFrame.java - user 추가 CreateRoomFrame.java – 방 만들기 cRoomFrame.java – chatting room GameEnding.java – ending 화면 GameRoom.java – 게임실 LoginFrame.java - 로그인 MoleGame.java – main() NetClient.java – client socket QuitDialog.java – Quit 버튼처리 UserInfo.java – 게임에 관한 정보관리 WaitRoomFrame.java - 대기실 Warning.java - 경고창

LoginFrame.java 로그인 화면  가입버튼을 누르면 AccountFrame 이 호출  기존의 가입자는 아이디와 비밀번호를 입력받아 info class 에서 usersearch() 를 통해 인증

LoginFrame.java 아이디와 패스워드 를 누르면 waring class 가 호출

AccountFrame.java 가입버튼을 누르면 AccountFrame 이 활 성화 아이디, 비밀번호, 이 름을 입력받아 Db 에 저장후 다시 LoginFrame 활성화

AccountFrame.java 소스 netClient.sendMessage("02 "+id+","+pass1+"."+name); w:while(true) { if (!(netClient.readMessage==null)) { String getMemo = netClient.readMessage,control=null; netClient.readMessage=null; control = getMemo.substring(0,2); getMemo = getMemo.substring(3,getMemo.length()); if (control.equals("00")) // 유저 추가 실패 { new Warning(this,getMemo); break w; } if (control.equals("01")) // 정확히 유저가 추가 { new Warning(this,getMemo); LoginFrame_Window(); break w; }

WaitRoomFrame.java 아이디를 클릭하면 그 사용자의 정보가 뜬다. – 아이디, 점수 만들어져 있는 방이 있다면 이 곳에 list 가 뜬다.

WaitRoomFrame.java class ServerInfo extends Thread // 서버와 계속적인 통신을 위해.. { String getMemo=null,control=null; String[] userList = new String[100]; String[] sRoomList = new String[100]; public void run() { boolean temp = false; while (true) { if (netClient.readMessage != null) { getMemo = netClient.readMessage; // 메시지를 받아와서 control = getMemo.substring(0,2); // 앞 2 문자만 때어내고 getMemo = getMemo.substring(3,getMemo.length()); // 나머지 netClient.readMessage = null; if (control.equals("03" )) // 만들어진 방목록 받기 { String buffer = null; boolean tmp = true; // 방리스트 갱신하기 - 없는 방목록 지우기 sRoomList = roomList.getItems(); for (int i=0; i<sRoomList.length;i++) if (getMemo.indexOf(sRoomList[i]) == -1) roomList.delItem(i);

cRoomFrmae.java 방 이름을 적고 확인 을 누르면 방이 만들 어 진다. 비밀번호를 만들고 싶으면 체크한 후 방을 만들면 비밀방을 만들 수 있다.

CreateRoomFrame.java 첫번째 User 의 Message 두번째 User 의 Message 텍스트필드 입력창

CreateRoomFrame.java 소스 class NetThread extends Thread { public void run() { String getMemo="",control=""; String[] temp = new String[8]; String tID =""; int time=0; w:while(true) { if (netClient.readMessage != null) { System.out.println(netClient.readMessage); getMemo=netClient.readMessage; // 메시지를 받아와서 control = getMemo.substring(0,2); // 앞 2 문자만 때어내고 getMemo = getMemo.substring(3,getMemo.length()); // 나머지 문자들 netClient.readMessage=null; if (control.equals("07")) // 방 정보를 받아옴 { int i=0; temp = textCutter("'", getMemo); label1.setText(" 방 이름 : "+temp[0]); user.roomMateID = textCutter(",",getMemo); } if (control.equals("08")) // 체팅 메시지를 받았을때 { tID = getMemo.substring(0,getMemo.indexOf(",")); getMemo = getMemo.substring(getMemo.indexOf(",")+1,getMemo.length());

GameRoom.java 게임화면  두더지가 튀어나오 면 마우스로 클릭하 여 잡는다.  클릭하면 점수가 올 라간다.

GameRoom.java 게임이 종료되면 점 수를 표시하고 변경 된 점수를 Db 에 저장 한 후 일정시간이 지 나면 다시 채팅방으 로 돌아간다.

GameRoom.java-Thread 부분 public void run() { while (true) { if (user.start==6) {GameRoomFrame_End();this.stop();} if (netClient.readMessage != null) { getMemo = netClient.readMessage; // 메시지를 받아와서 control = getMemo.substring(0,2); // 앞 2 문자만 때어내고 getMemo = getMemo.substring(3,getMemo.length()); // 나머지 문자 netClient.readMessage = null; if (control.equals("11")) // 게임준비 { user.start=1; System.out.println(" 게임준비 "); } else if (control.equals("12")) // 게임시작 { user.start=2; System.out.println(" 게임시작 "); } else if (control.equals("13")) // 게임중 { user.start=3; System.out.println(" 게임중 "); }

GameRoom.java-Event 부분 public void mouseClicked(MouseEvent me) { if ((me.getX() > 45 && me.getX() 118 && me.getY() < 138) && user.moleC[0][0] == true) { netClient.sendMessage("15 "+user.roomNum+","+user.id); // 서버에 내가 입력했다고 알려줌.. user.roomMateScore[0]++; } if ((me.getX() > 140 && me.getX() 118 && me.getY() < 138) && user.moleC[0][1] == true) { netClient.sendMessage("15 "+user.roomNum+","+user.id); user.roomMateScore[0]++; } if ((me.getX() > 235 && me.getX() 118 && me.getY() < 138) && user.moleC[0][2] == true) { netClient.sendMessage("15 "+user.roomNum+","+user.id); user.roomMateScore[0]++; }

마치며 … 2 조 신흥섭 권석진 김관수 최현식 김주호