图书管理系统是一个比较常见的课程设计课题
一般来说可以用jsp+servlet框架来实现, 这个可以通过自己的封装, 把路由精简一下, 也可以用最新的servlet注解, 也是比较方便开发的。最近的几个项目都是这么用的。
如果是比较复杂的项目还是推荐用spring全家桶, 这个非常常用
import javaawtBorderLayout;
import javaawtDimension;
import javaawtToolkit;
import javaxswingJFrame;
@SuppressWarnings("serial")
public class MainClass extends JFrame {
ControlSnake control;
Toolkit kit;
Dimension dimen;
public static void main(String[] args) {
new MainClass("my snake");
}
public MainClass(String s) {
super(s);
control = new ControlSnake();
controlsetFocusable(true);
kit = ToolkitgetDefaultToolkit();
dimen = kitgetScreenSize();
add(control);
setLayout(new BorderLayout());
setLocation(dimenwidth / 3, dimenheight / 3);// dimenwidth/3,dimenheight/3
setSize(FWIDTH, FHEIGHT);
setDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
}
public static final int FWIDTH = 315;
public static final int FHEIGHT = 380;
}
import javaawtColor;
import javaawtDimension;
import javaawtGraphics;
import javaawtPoint;
import javaawteventActionEvent;
import javaawteventActionListener;
import javaawteventKeyAdapter;
import javaawteventKeyEvent;
import javautilArrayList;
import javautilRandom;
import javaxswingJOptionPane;
import javaxswingJPanel;
import javaxswingTimer;
@SuppressWarnings("serial")
public class ControlSnake extends JPanel implements ActionListener {
Random rand;
ArrayList<Point> list, listBody;
String str, str1;
static boolean key;
int x, y, dx, dy, fx, fy, flag;
int snakeBody;
int speed;
public ControlSnake() {
snakeBody = 1;
str = "上下左右方向键控制 P键暂停";
str1 = "现在的长度为:" + snakeBody;
key = true;
flag = 1;
speed = 700;
rand = new Random();
list = new ArrayList<Point>();
listBody = new ArrayList<Point>();
x = 5;
y = 5;
listadd(new Point(x, y));
listBodyadd(listget(0));
dx = 10;
dy = 0;
fx = randnextInt(30) 10 + 5;// 2
fy = randnextInt(30) 10 + 5;// 2
setBackground(ColorBLACK);
setSize(new Dimension(318, 380));
final Timer time = new Timer(speed, this);
timestart();
addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent e) {
if (egetKeyCode() == 37) {
dx = -10;
dy = 0;
} else if (egetKeyCode() == 38) {
dx = 0;
dy = -10;
} else if (egetKeyCode() == 39) {
dx = 10;
dy = 0;
} else if (egetKeyCode() == 40) {
dx = 0;
dy = 10;
} else if (egetKeyCode() == 80) {
if (flag % 2 == 1) {
timestop();
}
if (flag % 2 == 0) {
timestart();
}
flag++;
}
}
});
}
public void paint(Graphics g) {
gsetColor(ColorWHITE);
gfillRect(0, 0, 400, 400);
gsetColor(ColorDARK_GRAY);
gdrawLine(3, 3, 305, 3);
gdrawLine(3, 3, 3, 305);
gdrawLine(305, 3, 305, 305);
gdrawLine(3, 305, 305, 305);
gsetColor(ColorPINK);
for (int i = 0; i < listBodysize(); i++) {
gfillRect(listBodyget(i)x, listBodyget(i)y, 9, 9);
}
gfillRect(x, y, 9, 9);
gsetColor(ColorORANGE);
gfillRect(fx, fy, 9, 9);
gsetColor(ColorDARK_GRAY);
str1 = "现在的长度为:" + snakeBody;
gdrawString(str, 10, 320);
gdrawString(str1, 10, 335);
}
public void actionPerformed(ActionEvent e) {
x += dx;
y += dy;
if (makeOut() == false) {
JOptionPaneshowMessageDialog(null, "重新开始");
speed = 700;
snakeBody = 1;
x = 5;
y = 5;
listclear();
listadd(new Point(x, y));
listBodyclear();
listBodyadd(listget(0));
dx = 10;
dy = 0;
}
addPoint(x, y);
if (x == fx && y == fy) {
speed = (int) (speed 08);//速度增加参数
if (speed < 200) {
speed = 100;
}
fx = randnextInt(30) 10 + 5;// 2
fy = randnextInt(30) 10 + 5;// 2
snakeBody++;// 2
} // 2
repaint();
}
public void addPoint(int xx, int yy) {
// 动态的记录最新发生的50步以内的移动过的坐标
// 并画出最新的snakeBody
if (listsize() < 100) {//蛇身长度最长为100
listadd(new Point(xx, yy));
} else {
listremove(0);
listadd(new Point(xx, yy));
}
if (snakeBody == 1) {
listBodyremove(0);
listBodyadd(0, listget(listsize() - 1));
} else {
listBodyclear();
if (listsize() < snakeBody) {
for (int i = listsize() - 1; i > 0; i--) {
listBodyadd(listget(i));
}
} else {
for (int i = listsize() - 1; listBodysize() < snakeBody; i--) {
listBodyadd(listget(i));
}
}
}
}
public boolean makeOut() {
if ((x < 3 || y < 3) || (x > 305 || y > 305)) {
return false;
}
for (int i = 0; i < listBodysize() - 1; i++) {
for (int j = i + 1; j < listBodysize(); j++) {
if (listBodyget(i)equals(listBodyget(j))) {
return false;
}
}
}
return true;
}
}
/贪吃蛇代码/
以上就是关于Java web 学生管理系统 要求给个源代码和包全部的内容,包括:Java web 学生管理系统 要求给个源代码和包、用java web小游戏源代码。期末结课老师让做,急用,谢了、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)