java--俄罗斯方块

一、先看一下游戏运行时的画面

 

二、代码部分

1. Cell.java

Cell.java:

package demo1;import java.awt.image.BufferedImage;
import java.util.Objects;/*
编写小方块类属性:行、列、每个小方格的图片方法:左移一格、右移一格、下落一格
编写小方格实体类*/
public class Cell {private int row;private int col;private BufferedImage image;public Cell() {}public Cell(int row, int col, BufferedImage image) {this.row = row;this.col = col;this.image = image;}public int getRow() {return row;}public void setRow(int row) {this.row = row;}public int getCol() {return col;}public void setCol(int col) {this.col = col;}public BufferedImage getImage() {return image;}public void setImage(BufferedImage image) {this.image = image;}@Overridepublic String toString() {return "Cell{" +"row=" + row +", col=" + col +", image=" + image +'}';}@Overridepublic boolean equals(Object o) {if (this == o) return true;if (o == null || getClass() != o.getClass()) return false;Cell cell = (Cell) o;return row == cell.row &&col == cell.col &&Objects.equals(image, cell.image);}@Overridepublic int hashCode() {return Objects.hash(row, col, image);}//编写左移一格方法public void left(){col--;}//编写右移一格方法public void right(){col++;}//编写下落一格方法public void drop(){row++;}
}
2. I.java

I.java:

package demo1;public class I extends Tetromino {public I() {cells[0] = new Cell(0, 4, Tetris.I);cells[1] = new Cell(0, 3, Tetris.I);cells[2] = new Cell(0, 5, Tetris.I);cells[3] = new Cell(0, 6, Tetris.I);//共计有两种旋转状态states = new State[2];//初始化两种状态的相对坐标states[0] = new State(0, 0, 0, -1, 0, 1, 0, 2);states[1] = new State(0, 0, -1, 0, 1, 0, 2, 0);}
}
3. J.java

J.java:

package demo1;public class J extends Tetromino {public J() {cells[0] = new Cell(0, 4, Tetris.J);cells[1] = new Cell(0, 3, Tetris.J);cells[2] = new Cell(0, 5, Tetris.J);cells[3] = new Cell(1, 5, Tetris.J);//共计有四种旋转状态states = new State[4];//初始化四种状态的相对坐标states[0] = new State(0, 0, 0, -1, 0, 1, 1, 1);states[1] = new State(0, 0, -1, 0, 1, 0, 1, -1);states[2] = new State(0, 0, 0, 1, 0, -1, -1, -1);states[3] = new State(0, 0, 1, 0, -1, 0, -1, 1);}
}
4. L.java

L.java:

package demo1;public class L extends Tetromino {public L() {cells[0] = new Cell(0, 4, Tetris.L);cells[1] = new Cell(0, 3, Tetris.L);cells[2] = new Cell(0, 5, Tetris.L);cells[3] = new Cell(1, 3, Tetris.L);//共计有四种旋转状态states = new State[4];//初始化四种状态的相对坐标states[0] = new State(0, 0, 0, -1, 0, 1, 1, -1);states[1] = new State(0, 0, -1, 0, 1, 0, -1, -1);states[2] = new State(0, 0, 0, 1, 0, -1, -1, 1);states[3] = new State(0, 0, 1, 0, -1, 0, 1, 1);}
}
5. O.java

O.java:

package demo1;public class O extends Tetromino {public O() {cells[0] = new Cell(0, 4, Tetris.O);cells[1] = new Cell(0, 5, Tetris.O);cells[2] = new Cell(1, 4, Tetris.O);cells[3] = new Cell(1, 5, Tetris.O);//共计有零种旋转状态states = new State[0];}
}
6. S.java

S.java:

package demo1;public class S extends Tetromino {public S() {cells[0] = new Cell(0, 4, Tetris.S);cells[1] = new Cell(0, 5, Tetris.S);cells[2] = new Cell(1,3, Tetris.S);cells[3] = new Cell(1, 4, Tetris.S);//共计有两种旋转状态states = new State[2];//初始化两种状态相对坐标states[0] = new State(0, 0, 0, 1, 1, -1, 1, 0);states[1] = new State(0, 0, 1, 0, -1, -1, 0, -1);}
}
7. T.java

T.java:

package demo1;public class T extends Tetromino {public T() {cells[0] = new Cell(0, 4, Tetris.T);cells[1] = new Cell(0, 3, Tetris.T);cells[2] = new Cell(0, 5, Tetris.T);cells[3] = new Cell(1, 4, Tetris.T);//共计有四种旋转状态states = new State[4];//初始化四种状态的相对坐标states[0] = new State(0, 0, 0, -1, 0, 1, 1, 0);states[1] = new State(0, 0, -1, 0, 1, 0, 0, -1);states[2] = new State(0, 0, 0, 1, 0, -1, -1, 0);states[3] = new State(0, 0, 1, 0, -1, 0, 0, 1);}
}
8. Tetris.java

Tetris.java:

package demo1;import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;//编写俄罗斯方块主类
public class Tetris extends JPanel {//声明正在下落的方块private Tetromino currentOne = Tetromino.randomOne();//声明将要下落的方块private Tetromino nextOne = Tetromino.randomOne();//声明游戏主区域private Cell[][] wall = new Cell[18][9];//声明单元格的值为48像素private static final int CELL_SIZE = 40;//声明游戏分数池int[] scores_pool = {0,1,2,5,10};//声明当前获得游戏的分数private int totalScore = 0;//当前已消除的行数private int totalLine = 0;//声明游戏的三种状态,分别是:游戏中、暂停、游戏结束public static final int PLAYING = 0;public static final int PAUSE = 1;public static final int GAMEOVER = 2;//声明变量存放当前游戏状态的值private int game_state;//声明一个数组,用来显示游戏状态String[] show_state = {"P[pause]","C[continue]","S[replay]"};//载入方块图片public static BufferedImage I;public static BufferedImage J;public static BufferedImage L;public static BufferedImage O;public static BufferedImage S;public static BufferedImage T;public static BufferedImage Z;public static BufferedImage backImage;static {try {I = ImageIO.read(new File("images/I.png"));J = ImageIO.read(new File("images/J.png"));L = ImageIO.read(new File("images/L.png"));O = ImageIO.read(new File("images/O.png"));S = ImageIO.read(new File("images/S.png"));T = ImageIO.read(new File("images/T.png"));Z = ImageIO.read(new File("images/Z.png"));backImage = ImageIO.read(new File("images/background.png"));} catch (IOException e) {e.printStackTrace();}}@Overridepublic void paint(Graphics g) {g.drawImage(backImage, 0, 0, null);//平移坐标轴g.translate(22, 15);//绘制游戏主区域paintWall(g);//绘制正在下落的四方格paintCurrentOne(g);//绘制下一个将要下落的四方格paintNextOne(g);//绘制游戏得分paintScore(g);//绘制游戏当前状态paintState(g);}public void start(){game_state = PLAYING;KeyListener l = new KeyAdapter() {@Overridepublic void keyPressed(KeyEvent e) {int code = e.getKeyCode();switch (code){case KeyEvent.VK_DOWN:sortDropAction(); //下落一格break;case KeyEvent.VK_LEFT:moveLeftAction(); //左移break;case KeyEvent.VK_RIGHT:moveRightAction(); //右移break;case KeyEvent.VK_UP:rotateRightAction(); //顺时针旋转break;case KeyEvent.VK_SPACE:handDropAction(); //瞬间下落break;case KeyEvent.VK_P://判断当前游戏的状态if(game_state == PLAYING){game_state = PAUSE;}break;case KeyEvent.VK_C://判断游戏状态if(game_state == PAUSE){game_state = PLAYING;}break;case KeyEvent.VK_S://表示游戏重新开始game_state = PLAYING;wall = new Cell[18][9];currentOne = Tetromino.randomOne();nextOne = Tetromino.randomOne();totalScore = 0;totalLine = 0;break;}}};//将俄罗斯方块窗口设置为焦点this.addKeyListener(l);this.requestFocus();while(true){//判断,当前游戏状态在游戏中时,每隔0.5秒下落if(game_state == PLAYING){try {Thread.sleep(500);} catch (InterruptedException e) {e.printStackTrace();}//判断能否下落if(canDrop()){currentOne.softDrop();}else{//嵌入到墙中landToWall();//判断能否消行destroyLine();//判断游戏是否结束if(isGameOver()){game_state = GAMEOVER;}else{currentOne = nextOne;nextOne = Tetromino.randomOne();}}}repaint();}}//创建顺时针旋转public void rotateRightAction(){currentOne.rotateRight();//判断是否越界或者是否重合if(outOfBounds() || coincide()){currentOne.rotateLeft();}}//瞬间下落public void handDropAction(){while(true){//判断四方格能否下落if(canDrop()){currentOne.softDrop();}else{break;}}//嵌入到墙中landToWall();//判断能否消行destroyLine();//判断游戏是否结束if(isGameOver()){game_state = GAMEOVER;}else{//游戏没有结束,继续生成新的四方格currentOne = nextOne;nextOne = Tetromino.randomOne();}}//按键一次四方格下落一格public void sortDropAction(){//判断能否下落if(canDrop()){//当前四方格下落一格currentOne.softDrop();}else{//将四方格嵌入到墙中landToWall();//判断能否消行destroyLine();//判断游戏是否结束if(isGameOver()){game_state = GAMEOVER;}else{//当游戏没有结束时,则继续生成新的四方格currentOne = nextOne;nextOne = Tetromino.randomOne();}}}//四方格嵌入到墙中private void landToWall() {Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();wall[row][col] = cell;}}//判断四方格能否下落public boolean canDrop(){Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();//判断是否到达底部if(row == wall.length - 1){return false;}else if(wall[row + 1][col] != null){ //判断是否有方块return false;}}return true;}//创建消行方法public void destroyLine(){//声明变量,统计当前消除的行数int line = 0;Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();//判断当前行是否已满if(isFullLine(row)){line++;for(int i = row;i > 0;i--){System.arraycopy(wall[i - 1],0,wall[i],0,wall[0].length);}wall[0] = new Cell[9];}}//在分数池中获取分数,累加到总分数中totalScore += scores_pool[line];//统计消除总行数totalLine += line;}//判断当前行是否已满public boolean isFullLine(int row){Cell[] cells = wall[row];for (Cell cell : cells) {if(cell == null){return false;}}return true;}//判断游戏是否结束public boolean isGameOver(){Cell[] cells = nextOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();if(wall[row][col] != null){return true;}}return false;}//绘制游戏当前状态private void paintState(Graphics g) {if(game_state == PLAYING){g.drawString(show_state[0],500,660);}else if(game_state == PAUSE){g.drawString(show_state[1],500,660);}else if(game_state == GAMEOVER){g.drawString(show_state[2],500,660);g.setColor(Color.red);g.setFont(new Font(Font.SANS_SERIF, Font.BOLD,60));g.drawString("GAMEOVER!", 30, 400);}}//绘制游戏得分private void paintScore(Graphics g) {g.setFont(new Font(Font.SANS_SERIF, Font.BOLD,30));g.drawString("SCORES: " + totalScore, 500, 248);g.drawString("LINES: " + totalLine, 500, 430);}//绘制下一个将要下落的四方格private void paintNextOne(Graphics g) {Cell[] cells = nextOne.cells;for (Cell cell : cells) {int x = cell.getCol() * CELL_SIZE + 370;int y = cell.getRow() * CELL_SIZE + 25;g.drawImage(cell.getImage(), x, y, null);}}//绘制正在下落的四方格private void paintCurrentOne(Graphics g) {Cell[] cells = currentOne.cells;for (Cell cell : cells) {int x = cell.getCol() * CELL_SIZE;int y = cell.getRow() * CELL_SIZE;g.drawImage(cell.getImage(), x, y, CELL_SIZE, CELL_SIZE, null);}}//绘制游戏主区域private void paintWall(Graphics g) {for(int i = 0;i < wall.length;i++){for(int j = 0;j < wall[i].length;j++){int x = j * CELL_SIZE;int y = i * CELL_SIZE;Cell cell = wall[i][j];//判断当前单元格是否有小方块,如果没有则绘制矩形,否则将小方块嵌入到墙中if(cell == null){g.drawRect(x, y, CELL_SIZE, CELL_SIZE);}else{g.drawImage(cell.getImage(), x, y, CELL_SIZE, CELL_SIZE,null);}}}}//判断游戏是否出界public boolean outOfBounds(){Cell[] cells = currentOne.cells;for (Cell cell : cells) {int col = cell.getCol();int row = cell.getRow();if(row < 0 || row > wall.length - 1 || col < 0 || col > wall[0].length - 1){return true;}}return false;}//判断方块是否重合public boolean coincide(){Cell[] cells = currentOne.cells;for (Cell cell : cells) {int row = cell.getRow();int col = cell.getCol();if(wall[row][col] != null){return true;}}return false;}//按键一次四方格左移一次public void moveLeftAction(){currentOne.moveLeft();//判断是否越界或者四方格是否重合if(outOfBounds() || coincide()){currentOne.moveRight();}}//按键一次四方格右移一次public void moveRightAction(){currentOne.moveRight();//判断是否越界if(outOfBounds() || coincide()){currentOne.moveLeft();}}public static void main(String[] args) {//创建一个窗口对象JFrame frame = new JFrame("俄罗斯方块");//创建游戏界面,也就是面板Tetris panel = new Tetris();//将面板嵌入到窗口中frame.add(panel);//设置可见frame.setVisible(true);//设置窗口尺寸frame.setSize(810, 940);//设置窗口居中frame.setLocationRelativeTo(null);//设置窗口关闭时程序终止frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//游戏主要逻辑封装在方法中panel.start();}
}
9. Tetromino.java

Tetromino.java:

package demo1;/*
编写四方格父类属性:Cell数组用于创建4个小方块方法:左移一格、右移一格、下落一格、变形(暂时不考虑)*/
public class Tetromino {protected Cell[] cells = new Cell[4];//编写旋转状态protected State[] states;//声明旋转次数protected int count = 10000;//编写顺时针旋转四方格方法public void rotateRight(){if(states.length == 0){return;}//旋转次数加1count++;State s = states[count % states.length];Cell cell = cells[0];int row = cell.getRow();int col = cell.getCol();cells[1].setRow(row + s.row1);cells[1].setCol(col + s.col1);cells[2].setRow(row + s.row2);cells[2].setCol(col + s.col2);cells[3].setRow(row + s.row3);cells[3].setCol(col + s.col3);}//编写逆时针旋转四方格方法public void rotateLeft(){//旋转次数减1count--;State s = states[count % states.length];Cell cell = cells[0];int row = cell.getRow();int col = cell.getCol();cells[1].setRow(row + s.row1);cells[1].setCol(col + s.col1);cells[2].setRow(row + s.row2);cells[2].setCol(col + s.col2);cells[3].setRow(row + s.row3);cells[3].setCol(col + s.col3);}//编写四方格旋转状态的内部类class State{//编写属性:存储四方格各元素的相对位置int row0,col0,row1,col1,row2,col2,row3,col3;public State() {}public State(int row0, int col0, int row1, int col1, int row2, int col2, int row3, int col3) {this.row0 = row0;this.col0 = col0;this.row1 = row1;this.col1 = col1;this.row2 = row2;this.col2 = col2;this.row3 = row3;this.col3 = col3;}public int getRow0() {return row0;}public void setRow0(int row0) {this.row0 = row0;}public int getCol0() {return col0;}public void setCol0(int col0) {this.col0 = col0;}public int getRow1() {return row1;}public void setRow1(int row1) {this.row1 = row1;}public int getCol1() {return col1;}public void setCol1(int col1) {this.col1 = col1;}public int getRow2() {return row2;}public void setRow2(int row2) {this.row2 = row2;}public int getCol2() {return col2;}public void setCol2(int col2) {this.col2 = col2;}public int getRow3() {return row3;}public void setRow3(int row3) {this.row3 = row3;}public int getCol3() {return col3;}public void setCol3(int col3) {this.col3 = col3;}@Overridepublic String toString() {return "State{" +"row0=" + row0 +", col0=" + col0 +", row1=" + row1 +", col1=" + col1 +", row2=" + row2 +", col2=" + col2 +", row3=" + row3 +", col3=" + col3 +'}';}}//编写左移方法public void moveLeft(){for (Cell cell : cells) {cell.left();}}//编写右移方法public void moveRight(){for (Cell cell : cells) {cell.right();}}//编写下落方法public void softDrop(){for (Cell cell : cells) {cell.drop();}}//编写随机生成四方格的方法public static Tetromino randomOne(){int num = (int)(Math.random() * 7);Tetromino tetromino = null;switch (num){case 0:tetromino = new I();break;case 1:tetromino = new J();break;case 2:tetromino = new L();break;case 3:tetromino = new O();break;case 4:tetromino = new S();break;case 5:tetromino = new T();break;case 6:tetromino = new Z();break;}return tetromino;}
}
10. Z.java

Z.java:

package demo1;public class Z extends Tetromino {public Z() {cells[0] = new Cell(1, 4, Tetris.Z);cells[1] = new Cell(0, 3, Tetris.Z);cells[2] = new Cell(0, 4, Tetris.Z);cells[3] = new Cell(1, 5, Tetris.Z);//共计有两种旋转状态states = new State[2];states[0] = new State(0, 0, -1, -1, -1, 0, 0, 1);states[1] = new State(0, 0, -1, 1, 0, 1, 1, 0);}
}

总结

↑:改变方位
←:向左移动
→:向右移动
↓:快速向下移动
空格:直接移动到最下面
P:暂停
C:开始

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/197665.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

kubectl 本地远程链接k8s多个集群,远程管控多集群,查看日志 部署服务(windows版)

文章目录 一、前言二、windows上安装kubectl和mobaxterm2.1 准备安装包2.2 安装kubectl2.3 链接k8s集群2.4 查看某一个pod的容器日志2.5 切换context 上下文配置&#xff0c;实现在多个k8s集群间动态切换 一、前言 现如今是一个万物皆上云 的时代&#xff0c;各种云层出不穷&am…

贝锐蒲公英路由器X4C如何远程访问NAS?

在目前网盘前路坎坷的情况下&#xff0c;私人云盘已然是一种新的趋势&#xff01;那自己打造一个私有云盘&#xff0c;是否需要高成本或是高门槛呢&#xff1f;其实并不用&#xff01;蒲公英针对个人玩家打造了全方位的私有云解决方案。 &#xff08;1&#xff09;入门级玩家只…

Web之HTML笔记

Web之HTML、CSS、JS Web标准一、HTML&#xff08;超文本标记语言&#xff09;HTML 基本结构标签常用标签1.font标签2.p标签3.注释4.h系列标题5.img6.超链接a7.列表8.表格9.表单 Web之CSS笔记 Web之JavaScript(jQuery)笔记 Web标准 结构标准用于对网页元素进行整理和分类(HTML…

Git-概念与架构

GIT-概念与架构 一、背景和起源二、版本控制系统1.版本控制分类1.1 集中式版本控制1.2 分布式版本控制 2.Git和SVN对比2.1 SVN2.2 GIT 三、GIT框架1.工作区&#xff08;working directory&#xff09;2.暂存区&#xff08;staging area&#xff09;3.本地仓库&#xff08;local…

在vmware中给linux添加硬盘

1.必须在断开linux电源的情况下&#xff0c;才能添加硬盘成功。注&#xff1a;自己好几次在开机状态下添加硬盘都失败了&#xff0c;然后关机后&#xff0c;又试了下&#xff0c;居然成功了。

鸿蒙APP外包开发需要注意的问题

在进行鸿蒙&#xff08;HarmonyOS&#xff09;应用开发时&#xff0c;开发者需要注意一些重要的问题&#xff0c;以确保应用的质量、性能和用户体验。以下是一些鸿蒙APP开发中需要特别关注的问题&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软…

Python学习(一)基础语法

文章目录 1. 入门1.1 解释器的作用1.2 下载1.3 基础语法输入输出语法与引号注释&#xff1a;变量&#xff1a; 数据类型与四则运算数据类型四则运算数据类型的查看type()数据类型的转换int()、int()、float() 流程控制格式化输出循环与遍历逻辑运算符list遍历字典dict遍历 跳出…

Java Web——JavaScript基础

1. 引入方式 JavaScript程序不能独立运行&#xff0c;它需要被嵌入HTML中&#xff0c;然后浏览器才能执行 JavaScript 代码。 通过 script 标签将 JavaScript 代码引入到 HTML 中&#xff0c;有3种方式&#xff1a; 1.1. 内嵌式(嵌入式) 直接写在html文件里&#xff0c;用s…

[C/C++]数据结构 链表OJ题:随机链表的复制

题目描述: 给你一个长度为 n 的链表&#xff0c;每个节点包含一个额外增加的随机指针 random &#xff0c;该指针可以指向链表中的任何节点或空节点。 构造这个链表的 深拷贝。 深拷贝应该正好由 n 个 全新 节点组成&#xff0c;其中每个新节点的值都设为其对应的原节点的值。新…

从零开始 通义千问大模型本地化到阿里云通义千问API调用

从零开始 通义千问大模型本地化到阿里云通义千问API调用 一、通义千问大模型介绍 何为“通义千问”&#xff1f; “通义千问大模型”是阿里云推出的一个超大规模的语言模型&#xff0c;具有强大的归纳和理解能力&#xff0c;可以处理各种自然语言处理任务&#xff0c;包括但…

Oracle主备切换,ogg恢复方法(集成模式)

前言: 文章主要介绍Oracle数据库物理ADG主备在发生切换时(switchover,failover)&#xff0c;在主库运行的ogg进程(集成模式)如何进行恢复。 测试恢复场景&#xff0c;因为集成模式不能在备库配置&#xff0c;所以场景都是基于主库端: 1 主备发生switchover切换&#xff0c;主库…

VUE(一)

1.vue简介 英文官网: Vue.js - The Progressive JavaScript Framework | Vue.js 中文官网: Vue.js - 渐进式 JavaScript 框架 | Vue.js 2.Vue的特点 3.初识VUE 在官网下载VUE.js,有两个版本&#xff0c;一个开发一个生产 <!DOCTYPE html> <html lang"en"…

贝锐蒲公英云AP,企业WiFi功能如何使用?

1. 功能介绍 基于WPA2-EAP安全认证技术&#xff0c;为企业提供了一套易用安全的企业无线网络,实现企业员工通过蒲公英客户端一键连接企业无线WiFi。自动分配一人一帐一密&#xff0c;无需配置证书或手动输入密码&#xff0c;减少沟通成本&#xff0c;方便快捷&#xff0c;提高…

前置语音群呼与语音机器人群呼哪个更好

最近通过观察自己接到的营销电话&#xff0c;通过语音机器人外呼的量应该有所下降。同时和客户交流获取到的信息&#xff0c;也是和这个情况类似&#xff0c;很多AI机器人群呼的量转向了OKCC前置语音群呼。询问原因&#xff0c;说是前置语音群呼转化更快&#xff0c;AI机器人群…

Android修行手册-POI操作中文API文档

Unity3D特效百例案例项目实战源码Android-Unity实战问题汇总游戏脚本-辅助自动化Android控件全解手册再战Android系列Scratch编程案例软考全系列Unity3D学习专栏蓝桥系列ChatGPT和AIGC &#x1f449;关于作者 专注于Android/Unity和各种游戏开发技巧&#xff0c;以及各种资源分…

pm2在Windows环境中的使用

pm2 进程管理工具可以Windows操作系统上运行&#xff0c;当一台Windows电脑上需要运行多个进程时&#xff0c;或者运维时需要运行多个进程以提供服务时。可以使用pm2&#xff0c;而不再是使用脚本。 1. 使用PM2管理进程 1.1. 启动PM2项目 1.1.1. 直接启动项目 参数说明&…

PostgreSQL 数据定义语言 DDL

文章目录 表创建主键约束非空唯一约束检查约束外键约束默认值约束 触发器表空间构建表空间 视图索引索引的基本概念索引的分类创建索引 物化视图 表创建 PostgreSQL表的构建语句与所有数据库都一样&#xff0c;结构如下&#xff0c;其核心在于构建表时&#xff0c;要指定上一些…

ACWSpring1.3

首先,前端写ajax写上我们的访问路径(就在我们前端的源代码里面),我们建了两个包pkController用于前端页面url映射过来一层一层找到我们的RestController返回bot1里面有键值,返回的这就是一个session对象bot1这个map.前端拿到我们bot1里的两个值给到我们前端显示出来 1准备页面:…

Linux:补充一些常用命令

Linux&#xff1a;补充一些常用命令 1. free -h2. df -lh3. du -sh *4. uname -a5. which6. mvn install 编译打包7. find -name *.jar8. cd -9. nohup java -jar *.jar &10. ps -ef|grep java11. netstat -ntlp 1. free -h free 命令显示系统使用和空闲的内存情况&#x…

Flutter笔记:缩放手势

Flutter笔记 缩放手势 作者&#xff1a;李俊才 &#xff08;jcLee95&#xff09;&#xff1a;https://blog.csdn.net/qq_28550263 邮箱 &#xff1a;291148484163.com 本文地址&#xff1a;https://blog.csdn.net/qq_28550263/article/details/134485138 目 录 1. 概述2. 缩放手…