@ -1,13 +0,0 @@
|
||||
package com.Drj.Object;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
|
||||
public class GoldMinidrj extends Golddrj{
|
||||
public GoldMinidrj() {
|
||||
this.width=36;
|
||||
this.height =36;//由于图片大小不同重新设置一个宽高
|
||||
this.m=15;//由于质量大小不同重新设置一个质量
|
||||
this.count=2;//设置积分
|
||||
this.img =Toolkit.getDefaultToolkit().getImage("image/gold0.gif");//由于图片不同重新设置一个路径
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.Drj.Object;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
|
||||
public class GoldPlusdrj extends Golddrj{
|
||||
public GoldPlusdrj() {
|
||||
//由于大金矿过大会溢出画面重新设置其坐标
|
||||
this.x=(int)(Math.random()*650);//金矿x轴随机位置的函数
|
||||
this.y=(int)(Math.random()*550+300);//金矿y轴随机位置的函数
|
||||
this.width=105;
|
||||
this.height =105;//由于图片大小不同重新设置一个宽高
|
||||
this.m=60;//由于质量大小不同重新设置一个质量
|
||||
this.count=8;//设置积分
|
||||
this.img =Toolkit.getDefaultToolkit().getImage("image/gold2.gif");//由于图片不同重新设置一个路径
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.Drj.Object;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
|
||||
public class Golddrj extends Objectdrj{
|
||||
boolean f=false;//用于判断是否被抓取
|
||||
public Golddrj() {
|
||||
this.x=(int)(Math.random()*700);//金矿x轴随机位置的函数
|
||||
this.y=(int)(Math.random()*550+300);//金矿y轴随机位置的函数
|
||||
this.width=52;//设置宽
|
||||
this.height =52;//设置高
|
||||
this.f=false;
|
||||
this.m=30;//设置质量
|
||||
this.count=4;//设置积分
|
||||
this.type=1;
|
||||
this.img =Toolkit.getDefaultToolkit().getImage("image/gold1.gif");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package com.Drj.Object;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
|
||||
public class Rockdrj extends Objectdrj{
|
||||
boolean f=false;//用于判断是否被抓取
|
||||
public Rockdrj() {
|
||||
this.x=(int)(Math.random()*700);//石头x轴随机位置的函数
|
||||
this.y=(int)(Math.random()*550+300);//石头y轴随机位置的函数
|
||||
this.width=71;
|
||||
this.height =71;
|
||||
this.f=false;
|
||||
this.m=50;
|
||||
this.count=1;//设置积分
|
||||
this.type=2;
|
||||
this.img =Toolkit.getDefaultToolkit().getImage("image/rock1.png");
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.Drj.shop;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import com.Drj.Bg.Bgdrj;
|
||||
import com.Drj.gameWin.gameWindrj;
|
||||
public class Shopdrj {
|
||||
public void mouseClicked(MouseEvent e,Bgdrj bg) {
|
||||
if(e.getButton()==1) {
|
||||
bg.shop=true;
|
||||
}
|
||||
if(e.getButton()==3) {
|
||||
gameWindrj.state=1;
|
||||
bg.startTime=System.currentTimeMillis();//给开始时间赋值为系统时间
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.Zsn.zhuce;
|
||||
|
||||
public class User{
|
||||
String username;
|
||||
String password;
|
||||
public User() {}
|
||||
public User(String username, String password) {
|
||||
super();
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package com.Zsn.zhuce;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
public class Users {
|
||||
public static boolean insert(String username,String password) {
|
||||
// TODO 自动生成的方法存根
|
||||
boolean flaguser=false;
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
String url="jdbc:mysql://localhost:3306/gold?userSSL=flase&serverTimezone=Asia/Shanghai";
|
||||
String user="root";
|
||||
String password1="asdasd123";
|
||||
Connection conn =DriverManager.getConnection(url,user,password1);
|
||||
String sql ="Insert into user (username,password) values(?,?)";
|
||||
PreparedStatement prestm=conn.prepareStatement(sql);
|
||||
prestm.setString(1,username);
|
||||
prestm.setString(2,password);
|
||||
if(prestm.executeUpdate()!=0) {
|
||||
flaguser=true;
|
||||
}
|
||||
prestm.close();
|
||||
conn.close();
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return flaguser;
|
||||
}
|
||||
public static boolean check(String username) {
|
||||
// TODO 自动生成的方法存根
|
||||
boolean flaguser=false;
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
String url="jdbc:mysql://localhost:3306/gold?userSSL=flase&serverTimezone=Asia/Shanghai";
|
||||
String user="root";
|
||||
String password1="asdasd123";
|
||||
Connection conn =DriverManager.getConnection(url,user,password1);
|
||||
String sql ="select *from user where username=?";
|
||||
PreparedStatement prestm=conn.prepareStatement(sql);
|
||||
prestm.setString(1,username);
|
||||
ResultSet rs=prestm.executeQuery();
|
||||
if(rs.next()) {
|
||||
flaguser=true;
|
||||
}
|
||||
rs.close();
|
||||
prestm.close();
|
||||
conn.close();
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return flaguser;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,135 @@
|
||||
package com.Zsn.zhuce;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPasswordField;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.Lhy.login.Login;
|
||||
|
||||
public class Zhuce extends JFrame implements ActionListener,MouseListener {
|
||||
private JTextField usernameText;
|
||||
private JPasswordField passwordText;
|
||||
private JButton zhuceButton1;
|
||||
private JButton cancelButton;
|
||||
private JLabel usernameLabel;
|
||||
private JLabel passwordLabel;
|
||||
public Zhuce() {
|
||||
this.setSize(768,1000);
|
||||
this.setUndecorated(true);
|
||||
this.setLocationRelativeTo(null);
|
||||
usernameLabel = new JLabel("用户:");
|
||||
usernameLabel.setBounds(250, 300, 90, 35);
|
||||
usernameLabel.setForeground(Color.white);
|
||||
usernameLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
||||
this.add(usernameLabel);
|
||||
usernameText = new JTextField();
|
||||
usernameText.setBounds(350, 300, 150, 35);
|
||||
usernameText.setFont(new Font("微软雅黑",Font.PLAIN,16));
|
||||
usernameText.setOpaque(false);
|
||||
usernameText.setBorder(null);
|
||||
usernameText.addMouseListener(this);
|
||||
this.add(usernameText);
|
||||
passwordLabel = new JLabel("密码:");
|
||||
passwordLabel.setBounds(250, 400, 90, 35);
|
||||
passwordLabel.setForeground(Color.white);
|
||||
passwordLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
||||
this.add(passwordLabel);
|
||||
passwordText = new JPasswordField();
|
||||
passwordText.setBounds(350, 400, 150, 35);
|
||||
passwordText.setOpaque(false);
|
||||
passwordText.setBorder(null);
|
||||
passwordText.addMouseListener(this);
|
||||
this.add(passwordText);
|
||||
zhuceButton1 = new JButton("注册");
|
||||
zhuceButton1.setFont(new Font("微软雅黑",Font.PLAIN,18));
|
||||
zhuceButton1.setBounds(300, 500, 100, 35);
|
||||
zhuceButton1.setForeground(Color.white);
|
||||
zhuceButton1.setOpaque(false);
|
||||
zhuceButton1.setContentAreaFilled(false);
|
||||
this.add(zhuceButton1);
|
||||
zhuceButton1.addActionListener(this);
|
||||
cancelButton = new JButton("返回");
|
||||
cancelButton.setFont(new Font("微软雅黑",Font.PLAIN,18));
|
||||
cancelButton.setBounds(450, 500, 100, 35);
|
||||
cancelButton.setOpaque(false);
|
||||
cancelButton.setContentAreaFilled(false);
|
||||
cancelButton.setForeground(Color.white);
|
||||
this.add(cancelButton);
|
||||
cancelButton.addActionListener(this);
|
||||
zhuceButton1.addActionListener(this);
|
||||
Zhucebg a=new Zhucebg();
|
||||
this.add(a);
|
||||
this.setVisible(true);
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
if(e.getSource()==usernameText)
|
||||
{
|
||||
usernameText.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
|
||||
}else if(e.getSource()==passwordText)
|
||||
{
|
||||
passwordText.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
if(e.getSource()==usernameText)
|
||||
{
|
||||
usernameText.setBorder(null);
|
||||
}else if(e.getSource()==passwordText)
|
||||
{
|
||||
passwordText.setBorder(null);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
if (e.getSource() == cancelButton) {
|
||||
this.setVisible(false);
|
||||
}
|
||||
else if (e.getSource() == zhuceButton1) {
|
||||
String name = usernameText.getText().trim();
|
||||
char[] password = passwordText.getPassword();
|
||||
String pass=String.valueOf(password);
|
||||
boolean b=Users.check(name);
|
||||
boolean a=Users.insert(name,pass);
|
||||
if(a&!b) {
|
||||
JOptionPane.showMessageDialog(this, "注册成功!");
|
||||
this.setVisible(false);
|
||||
}else {
|
||||
JOptionPane.showMessageDialog(this, "账户已有,请重新输入");
|
||||
usernameText.setText("");
|
||||
passwordText.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.Zsn.zhuce;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Zhucebg extends JPanel {
|
||||
private Image bg =Toolkit.getDefaultToolkit().getImage("image/bg.jpg");
|
||||
private Image tk =Toolkit.getDefaultToolkit().getImage("image/tk.jpg");
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
g.drawImage(tk,0,0,null);
|
||||
g.drawImage(bg,0,200,null);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue