提交 d8b2f5d4 编写于 作者: RunAtWorld's avatar RunAtWorld

天天跑酷

上级 333f384f
# Compiled class file
*.class
#MAC System File
.DS_Store
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
#bin
bin/
.idea/
*.iml
.settings/
.project/
.classpath/
/out
/node_modules
_book/
target/
out/
\ No newline at end of file
-- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jul 20, 2018 at 08:54 AM
-- Server version: 5.7.21
-- PHP Version: 5.6.35
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `daydayrun`
--
-- --------------------------------------------------------
--
-- Table structure for table `score`
--
DROP TABLE IF EXISTS `score`;
CREATE TABLE IF NOT EXISTS `score` (
`name` varchar(45) NOT NULL,
`score` int(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `score`
--
INSERT INTO `score` (`name`, `score`) VALUES
('null', 0),
('1', 1),
('qwe', 10),
('null', 0),
('null', 0),
('null', 0),
('12343', 11),
('123', 600),
('123', 300),
('123', 400),
('123', 1500),
('123', 1400),
('123', 600),
('123', 1300),
('123', 400),
('123', 1200),
('123', 200),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('sujiapei', 4300),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('null', 0),
('sujiapei', 300),
('1234', 1600),
('sujiapei', 300),
('null', 600),
('null', 2600),
('null', 700),
('null', 1400),
('null', 1500),
('null', 2200),
('null', 1400),
('null', 1500),
('null', 1100),
('null', 1400),
('null', 300),
('null', 2400),
('null', 2400),
('null', 1500),
('null', 1900),
('null', 3900),
('null', 2700),
('null', 2300),
('null', 2300),
('null', 400),
('null', 1100),
('null', 700),
('null', 2900),
('null', 3300),
('null', 800),
('null', 2900),
('null', 2700),
('null', 2000),
('null', 1200),
('null', 1400),
('null', 3000),
('null', 2500),
('sujiapei', 3800);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
`iduser` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`password` varchar(45) NOT NULL,
`Score` int(20) DEFAULT NULL,
PRIMARY KEY (`iduser`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`iduser`, `name`, `password`, `Score`) VALUES
(1, '123', '123', NULL),
(2, '1234', '1234', NULL),
(3, '1234', '1234', NULL),
(4, 'sujiapei', '1234', NULL);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
文件已添加
文件已添加
文件已添加
文件已添加
文件已添加
package com.yzu.daydayrun.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DBUtil {
private static String DriverClass;
private static String url;
private static String user;
private static String password;
static{
DriverClass ="com.mysql.jdbc.Driver";
url ="jdbc:mysql://localhost:3306/daydayrun?serverTimezone=UTC";
user ="root";
password = "123456";
try {
Class.forName(DriverClass);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static Connection getConnection() throws Exception{
return DriverManager.getConnection(url,user,password);
}
public static void closeAll(ResultSet rs, Statement stmt, Connection conn)
{
if(rs!=null)
{
try{
rs.close();
}
catch(Exception e){
e.printStackTrace();
}
}
if(stmt!=null)
{
try{
stmt.close();
}
catch(Exception e){
e.printStackTrace();
}
}
if(conn!=null)
{
try{
conn.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
}
\ No newline at end of file
package com.yzu.daydayrun.db;
import com.yzu.daydayrun.entity.User;
import com.yzu.daydayrun.utils.MD5;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class DoDenglu {
public User findUser(String name, String pwd)
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
User u =null;
try{
conn = DBUtil.getConnection();
String Sql = "select * from user where name=? and password=?";
stmt = conn.prepareStatement(Sql);
stmt.setString(1,name);
// MD5 md5 = new MD5();
// pwd = md5.MD5Encode(pwd);
stmt.setString(2,pwd);
// String sql ="select * from stu28 where Name = '"+name+"' AND PASsword = '"+pwd+"'";
// 这样写会导致SQL注入问题 就是后面 or '1'='1
rs = stmt.executeQuery();
if(rs.next())
{
u = new User();
u.setId(rs.getInt(1));
u.setName(rs.getString(2));
u.setPassword(rs.getString(3));
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
DBUtil.closeAll(rs, stmt, conn);
}
return u;
}
}
\ No newline at end of file
package com.yzu.daydayrun.db;
import com.yzu.daydayrun.entity.User;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class DoList {
public List<User> userList;
public List<User> GetList()
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try{
conn = DBUtil.getConnection();
String Sql = "select * from score order by score desc limit 3";
stmt = conn.prepareStatement(Sql);
rs = stmt.executeQuery();
userList = new ArrayList<User>();
while (rs.next())
{
User u=new User();
u.setName(rs.getString("name"));
u.setSocre(rs.getInt("score"));
userList.add(u);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
DBUtil.closeAll(rs, stmt, conn);
}
return userList;
}
}
package com.yzu.daydayrun.db;
import com.yzu.daydayrun.entity.User;
import com.yzu.daydayrun.utils.MD5;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class DoRegister {
private int flag;
private boolean Panchong;
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public User RegisterUser(String name, String pwd)
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
User u =null;
try{
conn = DBUtil.getConnection();
String SqlPanchong = "select * from user where name = '" + name + "'" ;
// System.out.println(SqlPanchong);
stmt = conn.prepareStatement(SqlPanchong);
Panchong = stmt.execute(SqlPanchong);
// System.out.println(Panchong);
if (Panchong!=true){
flag = 0;
}
else {
MD5 md5 = new MD5();
pwd = md5.MD5Encode(pwd);
String Sql = "insert into user(name,password)values('" + name + "','" + pwd + "')";
stmt = conn.prepareStatement(Sql);
flag = stmt.executeUpdate(Sql);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
DBUtil.closeAll(rs, stmt, conn);
}
return u;
}
}
\ No newline at end of file
package com.yzu.daydayrun.db;
import com.yzu.daydayrun.entity.User;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class DoWriteScore {
private int flag;
public int getFlag() {
return flag;
}
public User WriteScore(String name, int score){
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
User u =null;
try{
conn = DBUtil.getConnection();
String Sql = "insert into score(name,score)values('"+name+"','"+score+"')";
stmt = conn.prepareStatement(Sql);
flag=stmt.executeUpdate(Sql);
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
DBUtil.closeAll(rs, stmt, conn);
}
return u;
}
}
package com.yzu.daydayrun.entity;
import com.yzu.daydayrun.ui.MainFrame;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
public class Barrs_1 {
public static final int WIDTH = 120;
public static final int HEIGHT = 160;
private BufferedImage[] images;
private BufferedImage image;
private int x, y;
private int index;
private int xSpeed;
Random random = new Random();
public BufferedImage getImage() {
return image;
}
public void setImage(BufferedImage image) {
this.image = image;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public int getxSpeed() {
return xSpeed;
}
public void setxSpeed(int xSpeed) {
this.xSpeed = xSpeed;
}
public Barrs_1(){
images = new BufferedImage[2];
try {
images[0] = ImageIO.read(new File("D:/study/run-day/image/a4.png"));
images[1] = ImageIO.read(new File("D:/study/run-day/image/a2.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
index = 0;
x = MainFrame.WIDTH + random.nextInt(500);
y = 430 - HEIGHT;
xSpeed = 2;
}
public void step(){
image = images[index++/80 % images.length];
x -= xSpeed;
}
public void paintBarr_1(Graphics g){
g.drawImage(image, x, y, WIDTH, HEIGHT, null);
}
}
package com.yzu.daydayrun.entity;
import com.yzu.daydayrun.ui.MainFrame;
import java.awt.Graphics;
import java.awt.Image;
import java.util.Random;
import javax.swing.ImageIcon;
public class Gold {
public static final int WIDTH = 20;
public static final int HEIGHT = 20;
private Image image;
private int x, y;
private int xSpeed;
Random rd = new Random();
public Gold(){
image = new ImageIcon("D:/study/run-day/image/" + (rd.nextInt(6) + 20) + ".png").getImage();
x = rd.nextInt(200) + MainFrame.WIDTH;
y = rd.nextInt(300) + 50;
xSpeed = 2;
}
public void step(){
x -= xSpeed;
}
public void paintGold(Graphics g){
g.drawImage(image, x, y, WIDTH, HEIGHT, null);
}
public Image getImage() {
return image;
}
public void setImage(Image image) {
this.image = image;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getxSpeed() {
return xSpeed;
}
public void setxSpeed(int xSpeed) {
this.xSpeed = xSpeed;
}
}
package com.yzu.daydayrun.entity;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Person {
public static final int WIDTH = 90;
public static final int HEIGHT = 100;
private int x, y;
private int score;
private int distance;
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
private String username0;
private BufferedImage[] images;
public BufferedImage image;
public int life;
private int index;
public String getUsername0() {
return username0;
}
public void setUsername0(String username0) {
this.username0 = username0;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public BufferedImage getImage() {
return image;
}
public void setImage(BufferedImage image) {
this.image = image;
}
public int getLife() {
return life;
}
public void setLife(int life) {
this.life = life;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public Person() {
life = 10;
score = 0;
x = 50;
y = 315;
index = 0;
images = new BufferedImage[9];
try {
for (int i = 0; i < images.length; i++) {
images[i] = ImageIO.read(new File("D:/study/run-day/image/" + (i + 1) + ".png"));
}
} catch (IOException e) {
e.printStackTrace();
}
image = images[0];
}
public void step(){
image = images[index++/20%images.length];
}
public void drop(){
y += 2;
if(y >= 315){
y = 315;
}
}
public void paintPerson(Graphics g){
g.drawImage(image, x, y, WIDTH, HEIGHT, null);
}
}
package com.yzu.daydayrun.entity;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Pet {
private int dx, dy;
private BufferedImage[] dimages = new BufferedImage[6];
public BufferedImage dimage;
private int width, height;
private int index;
com.yzu.daydayrun.entity.Person p;
public int getDx() {
return dx;
}
public void setDx(int dx) {
this.dx = dx;
}
public int getDy() {
return dy;
}
public void setDy(int dy) {
this.dy = dy;
}
public BufferedImage getDimage() {
return dimage;
}
public void setDimage(BufferedImage dimage) {
this.dimage = dimage;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public Person getP() {
return p;
}
public void setP(Person p) {
this.p = p;
}
public Pet(Person p) {
this.p = p;
dimages = new BufferedImage[6];
try {
for (int i = 0; i < 6; i++) {
dimages[i] = ImageIO.read(new File("D:/study/run-day/image/d" + (i + 1) + ".png"));
}
} catch (IOException e) {
e.printStackTrace();
}
dx = p.getX() + 85;
dy = 345;
index = 0;
}
public void step(){
dimage = dimages[index++/10%dimages.length];
}
public void paintPet(Graphics g){
g.drawImage(dimage, dx, dy, null);
}
}
package com.yzu.daydayrun.entity;
import com.yzu.daydayrun.ui.MainFrame;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;
public class Stair {
public static final int WIDTH = 200;
public static final int HEIGHT = 37;
private BufferedImage image;
private int x, y;
private int xSpeed;
private int index;
Random random = new Random();
public BufferedImage getImage() {
return image;
}
public void setImage(BufferedImage image) {
this.image = image;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getxSpeed() {
return xSpeed;
}
public void setxSpeed(int xSpeed) {
this.xSpeed = xSpeed;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public Stair() {
try {
image = ImageIO.read(new File("D:/study/run-day/image/hhh.png"));
}
catch (IOException e) {
e.printStackTrace();
}
index = 0;
x = random.nextInt(500)+MainFrame.WIDTH;
y = 270-random.nextInt(150);
xSpeed = 2;
}
public void step() {
x -= xSpeed;
}
public void paintStair(Graphics g) {
g.drawImage(image, x, y, WIDTH, HEIGHT, null);
}
}
\ No newline at end of file
package com.yzu.daydayrun.entity;
public class User {
private int rgflag;
private int id;
private String name;
private String password;
private int socre;
public int getSocre() {
return socre;
}
public void setSocre(int socre) {
this.socre = socre;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getRgflag() {
return rgflag;
}
public void setRgflag(int rgflag) {
this.rgflag = rgflag;
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册