用java编写飞机大战

游戏界面使用JFrame和JPanel构建。背景图通过BG类绘制。英雄机和敌机在界面上显示并移动。子弹从英雄机发射并在屏幕上移动。游戏有四种状态:READY、RUNNING、PAUSE、GAMEOVER。状态通过鼠标点击进行切换:点击开始游戏(从READY变为RUNNING)。点击重新开始游戏(从GAMEOVER变为READY)。鼠标移出窗口时游戏暂停(从RUNNING变为PAUSE)。鼠标移入窗口时游戏继续(从PAUSE变为RUNNING)。开局默认玩家生命值为3,分数为0。每隔一定时间随机生成敌机(小飞机、大飞机、小飞碟)。敌机在屏幕上移动,并与英雄机进行碰撞检测。英雄机可以发射子弹。子弹在屏幕上移动,并与敌机进行碰撞检测。英雄机与敌机发生碰撞时,英雄机会损失一条生命值。子弹与敌机发生碰撞时,敌机会被摧毁,玩家的分增加。当子弹与奖励机发生碰撞时,奖励机会被摧毁,玩家随机获得两张奖励(生命值加1、双倍子弹)。在屏幕左上角显示当前的生命值和得分。生命值减少到0时,游戏进入结束状态。再次点击,重新开始游戏。

1.图片素材(百度网盘分享)

链接:https://pan.baidu.com/s/10QiTcddI_Zxw5jbn8fmOpA?pwd=huan 
提取码:huan

2.主页面world.java

package plane.gzeu;import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;public class World extends JPanel {//ImageIcon类:保存图片的路径----->读取图片
//    ImageIcon icon = new ImageIcon("images\\background.png");
//    BG bg = new BG(0,0,420,700,2);
//    Airplane airplane = new Airplane(100,200,300,620,2);
//    Bee bee = new Bee(200,100,200,700,2);BG bg = new BG();EnemyPlane [] planes;Hero hero;int index; //用来控制敌机的数量Bullet[] bullets;  //创建子弹的数组int life; //英雄机的生命值int score; //分数//定义游戏的四种状态:准备,运行,暂停,结束(常量)public static final int READY = 0;public static final int RUNNING = 1;public static final int PAUSE = 2;public static final int GAMEOVER = 3;//游戏的初始状态int state = READY;//    Airplane [] airPlanes = new Airplane[10];
//    Bigairplane [] bigAirPlanes = new Bigairplane[10];
//    Bee [] bee = new Bee[10];
//    Bom [] bom = new Bom[4];
//    Bullet [] bullets = new Bullet[3];
//    Hero [] hero =new Hero[2];//初始化方法public void init(){bg = new BG();hero = new Hero();planes = new EnemyPlane[0]; //默认一个敌机都没有bullets = new Bullet[0];  //默认一个子弹都没有index = 0; //默认从0开始life = 3; //默认3条命score = 0; //分数为0}public World() {init();//        for(int i=0;i<planes.length;i++){
//            if(i%2==0){
//                planes[i]=new Airplane();
//            }
//            else if(i%5==0 && i%2!=0){
//                planes[i] = new Bee();
//            }
//            else {
//                planes[i] = new Bigairplane();
//            }
//        }
//        for(int i =0;i<airPlanes.length;i++){
//            airPlanes[i] = new Airplane();
//            bigAirPlanes[i]=new BigAirPlane();
//            bee[i]=new Bee();
//            bom[i]=new Bom();
//            bullets[i]=new Bullet();
//            hero[i]=new Hero();}//生成敌机的方法public void createPlane(){if(index%16==0){int n = (int)(Math.random()*10);EnemyPlane plane;switch (n){case 9 :plane = new Bee(); //10%生成小飞碟break;case 8 :case 7 :plane = new Bigairplane(); //20%生成大飞机break;default:plane = new Airplane(); //70%生成小飞机}//将敌机存入数组中之前,要先对数组进行扩容处理planes = Arrays.copyOf(planes,planes.length+1);//将生存的敌机放入数组的最后一个位置planes[planes.length-1] = plane;}}//        for(int i =0;i<bigAirPlanes.length;i++){
//            bigAirPlanes[i]=new Bigairplane();
//       }
//    }//绘制图片printing@Overridepublic void paint(Graphics g) { //paint挂载到当前类,当前类实例化(创建对象)时自动调用
//      super.paint(g);
//      icon.paintIcon(this,g,0,y1++); //绘制背景,默认第一个绘制
//        bg.icon.paintIcon(this,g,(int)bg.x,(int)bg.y);
//      bg.move();
//        airplane.icon.paintIcon(this,g,(int)airplane.x,(int)airplane.y);
//        bee.icon.paintIcon(this,g,(int)bee.x,(int)bee.y);bg.painting(g);hero.painting(g);for(int i=0;i<planes.length;i++){planes[i].painting(g);}for(int i=0;i<bullets.length;i++){bullets[i].painting(g);}g.setColor(new Color(255,255,255));//设置字体g.setFont(new Font("微软雅黑",Font.BOLD,20));g.drawString("生命值"+life,20,20);g.drawString("分数"+score,20,40);if(state==READY){Images.start.paintIcon(this,g,0,0);}if(state==PAUSE){Images.pause.paintIcon(this,g,0,0);}if(state==GAMEOVER){Images.gameover.paintIcon(this,g,0,0);}//            for(int i =0;i<airPlanes.length;i++){
//                airPlanes[i].painting(g);
//            bigAirPlanes[i].painting(g);
//            bee[i].painting(g);
//            bom[i].painting(g);
//            bullets[i].painting(g);
//            hero[i].painting(g);
//            }
//            for(int i =0;i<bigAirPlanes.length;i++){
//                bigAirPlanes[i].painting(g);
//            }repaint();//刷新窗口}public static void main(String[] args) {//1.显示画框(外层):JFrameJFrame jf = new JFrame();//2.显示面板:JpanelWorld jp =new World();//3.将面板放入画框中:jf.add(jp);//对窗口进行设置jf.setTitle("我的窗口");//设置标题jf.setSize(436,700); //设置窗口大小jf.setLocationRelativeTo(null); //居中显示jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置关闭窗口后自动结束程序//4.显示窗口jf.setVisible(true);jp.action();}//唤醒定时器的方法public void action(){java.util.Timer timer = new Timer();MyTesk mt = new MyTesk();timer.schedule(mt,1000,1000/50);this.addMouseListener(new MouseAdapter() {//监听鼠标点击@Overridepublic void mouseClicked(MouseEvent e) {if(state==READY){state=RUNNING;}if(state==GAMEOVER){state=READY;init();}}//鼠标移除@Overridepublic void mouseExited(MouseEvent e) {
//                System.out.println("鼠标移出");if(state==RUNNING){state=PAUSE;}}//鼠标移入@Overridepublic void mouseEntered(MouseEvent e) {if(state==PAUSE){state=RUNNING;}}});//匿名内部类MouseAdapter mouseAdapter = new MouseAdapter() {@Overridepublic void mouseMoved(MouseEvent e) {if(state==RUNNING){int x = e.getX();int y = e.getY();hero.move(x,y);}}};//安装监听器this.addMouseMotionListener(mouseAdapter);}public void createBullet(){if(!hero.isLiving()){ //英雄机死亡不发射子弹return;}if(index%17==0){Bullet[] bullets1 = hero.double_fire();//俩个数组的合并Bullet[] arr = Arrays.copyOf(bullets,bullets.length+bullets1.length);System.arraycopy(bullets1,0,arr,bullets.length,bullets1.length);bullets = arr;
//            Bullet bullet =hero.fire();  //英雄机调用fire方法生成子弹
//            //将子弹放入数组中
//            bullets = Arrays.copyOf(bullets,bullets.length+1); //子弹扩容
//            bullets[bullets.length-1] = bullet;}}//加分的方法public void addScore(FlyingObjesct plane){if(plane.isDead()){if(plane instanceof Enemy){Enemy enemy = (Enemy) plane; //需要做一个强制转化score += enemy.getScore();}if(plane instanceof Aword){Aword aword = (Aword) plane;int  type =aword.getAword();if(type == Aword.DOUBLE_FIRE){hero.getdouble_fire();}if(type == Aword.LIFE){life++;}}}}//检测敌机与英雄机的碰撞public void hero_hit(){if(hero.isLiving()){for(int i=0;i<planes.length;i++){if(!planes[i].isLiving()){continue;}if(hero.bong(planes[i])){hero.goDead();planes[i].goDead();break;}}}else if(hero.isWait()){ //僵尸状态if(life>1){//重新开始hero = new Hero();//清屏for(int i=0;i<planes.length;i++){planes[i].goDead();}life--;}else{life--;state=GAMEOVER;}}}//检测每个敌机与子弹的碰撞情况public void hit(){for(int i=0;i<bullets.length;i++){Bullet bullet = bullets[i]; //拿出每一颗子弹if(!bullet.isLiving()){continue;}for(int j=0;j<planes.length;j++){FlyingObjesct p = planes[j];if(!p.isLiving()){continue;}if(p.bong(bullet)){  //被击中p.attack();bullet.goDead();addScore(p);}}}}//清理爆炸的飞机public void clean(){//清除飞机EnemyPlane[] living = new EnemyPlane[planes.length];int index = 0;for(int i=0;i<planes.length;i++){  //遍历敌机数组if(planes[i].isWait() || planes[i].outOfBound()){  //如果是等待状态的效果就跳过continue;}living[index++] = planes[i];  //将不是等待状态的敌机存在living里面}planes = Arrays.copyOf(living,index);//清除子弹Bullet[] livingBullet = new Bullet[bullets.length];index = 0;for(int i=0;i<bullets.length;i++){if(bullets[i].isDead() || bullets[i].outOfBound()){    //如果是已经爆炸的子弹就跳过continue;}livingBullet[index++] = bullets[i];}bullets = Arrays.copyOf(livingBullet,index);}class MyTesk extends TimerTask {@Overridepublic void run() {index++;if(state == RUNNING){createPlane(); //调用生成敌机的方法createBullet(); //调用生成子弹的方法hit();//调用子弹击打的效果clean(); //调用清理敌机方法hero_hit();bg.move();for(int i =0;i<planes.length;i++){planes[i].move();}for(int i =0;i<bullets.length;i++){bullets[i].move();}}}}
}

3.小飞机类Airplane.java

package plane.gzeu;import javax.swing.*;
//飞机类
public class Airplane extends EnemyPlane implements Enemy{ // 实现接口时,要实现接口中的方法public Airplane(){this.images = Images.airplane;w = images[0].getIconWidth();h = images[0].getIconHeight();x=(int)(Math.random()*(420-images[0].getIconWidth()));y=-2*images[0].getIconHeight();this.step=(Math.random()*2.5+0.7);this.icon=new ImageIcon("images\\airplane1.png");
//        this.icon = Images.airplane[0];}public Airplane(double x, double y, double w, double h,double speed) {
//        super(x, y, w, h);this.step=speed;this.icon=Images.airplane[0];}@Overridepublic int getScore() {return 10;}
}

4.大飞机类Bigairplane

package plane.gzeu;//大飞机类
public class Bigairplane extends EnemyPlane implements Enemy{public Bigairplane(double x, double y, double w, double h,double step) {
//        super(x, y, w, h);this.step=step;this.icon = Images.bigairplane[0];}public Bigairplane(){this.images = Images.bigairplane; //初始化数组w = images[0].getIconWidth();h = images[0].getIconHeight();x=(int)(Math.random()*(420-images[0].getIconWidth()));y=-2*images[0].getIconHeight();this.step=(Math.random()*3.5+0.7);
//        this.icon = Images.bigairplane[0];life = 4;}@Overridepublic int getScore() {return 50;}
}

5.英雄机类Hero.java

package plane.gzeu;import javax.swing.*;import static plane.gzeu.Images.bullet;public class Hero  extends EnemyPlane{public Hero(){this.images = Images.hero;x=431/2-images[0].getIconWidth()/2;y=510;w=images[0].getIconWidth();h=images[0].getIconHeight();
//        this.speed=0.2;this.icon = Images.hero[0];}public Hero(double x, double y, double w, double h,double step) {
//        super(x, y, w, h);this.step=step;
//        this.icon = new ImageIcon("images\\hero1.png"); //设置了Images类直接调用类名就可以引用图片this.icon = Images.hero[0];}@Overridepublic void move() {}//接收鼠标的坐标public void move(int x,int y) {this.x= x-images[0].getIconWidth()/2;this.y = y-images[0].getIconHeight()/2;}/** 子弹的位置(在英雄机上) b.x = h.x-images[0].getIconWidth()/2; b.y=h.y* 子弹的移动:向上:b.y-=b.step;* 子弹是无限的:数序扩容* 射击方法:当英雄机调用一次射击方法时,就发射一个子弹* *///射击的方法public Bullet fire(){double x = this.x+w/2-4; //获取英雄机的x坐标Bullet bullet = new Bullet(x,y);//将处理过后的坐标传给子弹return bullet; //将子弹返回}//获取双倍子弹的方法int doubleTime = 0; // 双倍子弹的时间,20次public void getdouble_fire(){doubleTime = 20;}//双倍子弹方法public Bullet[] double_fire(){if(doubleTime>0){double x = this.x+w/2-7;double x1 = this.x+w/2-2; //获取英雄机的x坐标Bullet bullet1 = new Bullet(x,y);Bullet bullet2 = new Bullet(x1,y);//将处理过后的坐标传给子弹Bullet [] bullets = new Bullet[]{bullet1,bullet2};
//            return new Bullet[]{bullet1,bullet2};return bullets;}else {double x = this.x+w/2-4; //获取英雄机的x坐标Bullet bullet1 = new Bullet(x,y);return new Bullet[]{bullet1};}
//}//测试
//    public static void main(String[] args) {
//        Hero hero = new Hero();
//        hero.move(200,300);
//        Bullet bullet = hero.fire();
//        System.out.println(bullet.x+"  "+bullet.y);
//    }
}

6.敌机类Bee.java

package plane.gzeu;import javax.swing.*;public class Bee extends EnemyPlane implements Aword {double speed1;public Bee(){this.images = Images.bee;w = images[0].getIconWidth();h = images[0].getIconHeight();x=(int)(Math.random()*(420-images[0].getIconWidth()));y=-2*images[0].getIconHeight();this.step=(Math.random()*4.5+2.5);this.speed1=(Math.random()*3.5+0.5);
//        this.icon=new ImageIcon("images\\bee0.png");this.icon=Images.bee[0];life = 6;}public Bee(double x, double y, double w, double h,double step) {
//        super(x, y, w, h);this.step=step;this.icon = Images.bee[0];}@Overridepublic void move() {y+=speed1;x+=step;if(x>431-images[0].getIconWidth()){step = -step;}if(x<=0){step = -step;}}@Overridepublic int getAword() {return Math.random()>0.5?DOUBLE_FIRE:LIFE;}
}

7.背景类BG.java

package plane.gzeu;import javax.swing.*;
import java.awt.*;//背景类(子类)
//继承FlyingObjesct类,得到FlyingObjesct类的方法及属性
public class BG extends FlyingObjesct {double y0;public BG(){x = 0;y = 0;icon = Images.bg;w = icon.getIconWidth();h = icon.getIconHeight();y0 = -h;step = 2;}public BG(double x, double y, double w, double h,double step) {super(x, y, w, h); //重载:调用父类的构造方法,实现方法复用this.step = step;this.icon = Images.bg; //背景是固定的}public void painting(Graphics g){icon.paintIcon(null,g,(int)x,(int)y);icon.paintIcon(null,g,(int)x,(int)y0);}@Overridepublic void move() {y+=step;y0+=step;if(y>=h){y=-h;}if(y0>=h){y0=-h;}}
}

8.爆炸类Bom.java

package plane.gzeu;import javax.swing.*;public class Bom extends EnemyPlane{public Bom(){x=(int)(Math.random()*370);y=(int)(Math.random()*370);this.step = 0.2;this.icon = Images.bom[0];}public Bom(double x, double y, double w, double h, double speed) {//要重写父类的构造方法。新增一个速度
//        super(x, y, w, h);//重载:调用父类的构造方法,实现方法复用this.step=speed;this.icon=Images.bom[0];}
}

9.子弹类Bullet.java

package plane.gzeu;import javax.swing.*;//继承FlyingObjesct类,得到FlyingObjesct类的方法及属性
public class Bullet extends EnemyPlane {public Bullet(double x,double y){this.icon = Images.bullet;w = icon.getIconWidth();h = icon.getIconHeight();this.x = x;this.y = y;step = 2;}public Bullet(){x=(int)(Math.random()*370);y=(int)(Math.random()*370);this.step = 0.2;this.icon = Images.bullet;}public Bullet(double x, double y, double w, double h, double step) {
//        super(x, y, w, h); //重载:调用父类的构造方法,实现方法复用this.step = step;this.icon = Images.bullet; //背景是固定的}@Overridepublic void move() {y-=step;}
}

10.三种敌机总类EnemyPlane.java

package plane.gzeu;
public abstract class EnemyPlane extends FlyingObjesct {@Overridepublic void move() {y+=step;}
}

11.飞行物的总类(父类)FlyingObjesct.java

package plane.gzeu;import javax.swing.*;
import java.awt.*;//飞行物的总类(父类)
public abstract class FlyingObjesct {public static final int LIVING = 1; //活着public static final int DEAD = 0; //死亡public static final int WAIT = -1;  //等待死亡(播放爆炸动画)//飞机默认是活着的public int state = LIVING;//飞机的生命值public int life = 2;public double x,y,step,w,h;//step速度public ImageIcon icon; //图片
//    Images images;public ImageIcon[] images; //数组public int index = 0;public ImageIcon [] boms = Images.bom; //存放爆炸效果的图片//赋初值:构造方法//快速生成构建方法:快捷键Alt+Insertpublic FlyingObjesct(double x, double y, double w, double h) {this.x = x;this.y = y;this.w = w;this.h = h;}//当飞机击打一次,生命值减一,当生命值为0时,进入死亡状态public boolean attack(){if(life>0){life--;if(life==0){state = DEAD;}return true;}return false;}
//让敌机快速去死public boolean goDead(){if(state==LIVING){life = 0;state = DEAD;return true;}else{return false;}}//判断飞机的三种状态public boolean isLiving(){return state==LIVING;  //判断是否活着}public boolean isDead(){return state==DEAD;  //判断是否死了}public boolean isWait(){return state==WAIT;  //判断是否等待死亡}/*实现动画效果* 1.用数组存储动画效果图片* 2.初始化数组* 3.定义一个计数器,作为切换图片的控制条件* 4.写一个方法,实现切换图片的操作* */int i;public void nextImage(){switch (state){case LIVING:if(images == null) {return;}icon = images[index++/300%images.length]; //0-[数组的长度-1]break;case DEAD:if(boms==null){return;}if(i++/300==boms.length){state = WAIT;return;}icon = boms[i++/300];}}public FlyingObjesct(){}//无参构造//移动public abstract void move();//绘制图形 方法public void painting(Graphics g){nextImage();icon.paintIcon(null,g,(int)x,(int)y);}//检测敌机是否碰到子弹:判断条件中心距c=H/2+h/2public boolean bong(FlyingObjesct bullet){FlyingObjesct p =this;double a = Math.min(p.w,p.h)/2;double b = Math.min(bullet.w,bullet.h)/2;double x1=p.x+p.w/2;double y1=p.y+p.h/2;double x2=bullet.x+bullet.w/2;double y2=bullet.y+bullet.h/2;double c = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));return c<=a+b;}//清除越界的敌机和子弹条件: y<-h-100 || y>700+100public boolean outOfBound(){if(y<-h-100){return true;}else if(y>700+100){return true;}return false;}
}

12.图片类Images.java

package plane.gzeu;import javax.swing.*;public class Images {public static ImageIcon bg;public static ImageIcon bullet;public static ImageIcon start;public static ImageIcon pause;public static ImageIcon gameover;public static ImageIcon[] hero;public static ImageIcon[] bigairplane;public static ImageIcon[] bee;public static ImageIcon[] airplane;public static ImageIcon[] bom;static {airplane = new ImageIcon[2];airplane[0] = new ImageIcon("images/airplane0.png");airplane[1] = new ImageIcon("images/airplane1.png");bigairplane = new ImageIcon[2];bigairplane[0] = new ImageIcon("images/bigairplane0.png");bigairplane[1] = new ImageIcon("images/bigairplane1.png");bee = new ImageIcon[2];bee[0] = new ImageIcon("images\\bee0.png");bee[1] = new ImageIcon("images\\bee1.png");bom = new ImageIcon[4];bom[0] = new ImageIcon("images/bom1.png");bom[1] = new ImageIcon("images/bom2.png");bom[2] = new ImageIcon("images/bom3.png");bom[3] = new ImageIcon("images/bom4.png");bg = new ImageIcon("images\\background.png");bullet = new ImageIcon("images\\bullet.png");start = new ImageIcon("images\\start.png");pause = new ImageIcon("images\\pause.png");gameover = new ImageIcon("images\\gameover.png");hero = new ImageIcon[2];hero[0] = new ImageIcon("images\\hero0.png");hero[1] = new ImageIcon("images\\hero1.png");}//测试图片是否传过来了public static void main(String[] args) {System.out.println(start.getImageLoadStatus()); //如果输出8那图片传过来了,输出其他数字有问题System.out.println(bg.getImageLoadStatus());System.out.println(bom[0].getImageLoadStatus());System.out.println(bee[1].getImageLoadStatus());System.out.println(airplane[1].getImageLoadStatus());}}

13.获得奖励的接口Aword.java

package plane.gzeu;
//获得奖励的接口
public interface Aword {int DOUBLE_FIRE = 1; //第一种奖励,双倍火力int LIFE = 2; //加生命值int getAword(); //获得奖励的方法
}

14.获得分数的接口Enemy.java

package plane.gzeu;
//获得分数的接口
public interface Enemy { //加分
//    int a = 5;//都是静态常量
//    public abstract void add(); //都是抽象方法public int getScore(); //获得分数的方法
}

运行界面:

开始界面

存活界面:

暂停界面

结束界面

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

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

详解Redis分布式锁在SpringBoot的@Async方法中没锁住的坑

背景 Redis分布式锁很有用处&#xff0c;在秒杀、抢购、订单、限流特别是一些用到异步分布式并行处理任务时频繁的用到&#xff0c;可以说它是一个BS架构的应用中最高频使用的技术之一。 但是我们经常会碰到这样的一个问题&#xff0c;那就是我们都按照标准做了但有时运行着、…

JavaEE之多线程进阶-面试问题

一.常见的锁策略 锁策略不是指某一个具体的锁&#xff0c;所有的锁都可以往这些锁策略中套 1.悲观锁与乐观锁 预测所冲突的概率是否高&#xff0c;悲观锁为预测锁冲突的概率较高&#xff0c;乐观锁为预测锁冲突的概率更低。 2.重量级锁和轻量级锁 从加锁的开销角度判断&am…

【Docker】03-自制镜像

1. 自制镜像 2. Dockerfile # 基础镜像 FROM openjdk:11.0-jre-buster # 设定时区 ENV TZAsia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 拷贝jar包 COPY docker-demo.jar /app.jar # 入口 ENTRYPOINT ["ja…

【强训笔记】day26

NO.1 思路&#xff1a;只需判断长度为2和3的回文子串。 代码实现&#xff1a; #include<iostream> #include<string>using namespace std;string s;int main() {cin>>s;int ns.size(),ret-1;for(int i0;i<n;i){if(i1<n&&s[i]s[i1]){ret2;}i…

笔试题总结

1.对于线性表的描述&#xff1a;存储空间不一定是连续&#xff0c;且各元素的存储顺序是任意的 2.虚函数的定义&#xff1a;函数的返回值参数不定&#xff0c; 声明&#xff1a; 类型&#xff0c;返回这类型 名字&#xff08;&#xff09;&#xff1b; 例如声明一个虚函数&a…

57.对称二叉树

迭代 class Solution {public boolean isSymmetric(TreeNode root) {if(rootnull){return true;}Deque<TreeNode> denew LinkedList<>();TreeNode l,r;int le;de.offer(root.left);de.offer(root.right);while(!de.isEmpty()){lde.pollFirst();rde.pollLast();if(…

二、图解C#教程

一、方法 {}块&#xff0c;里面的是方法体 二、Var关键字 推断出等号右边的实际类型 三、局部常量 1、声明时必须初始化 2、声明后不能改变

高效医疗:Spring Boot医院管理解决方案

1系统概述 1.1 研究背景 如今互联网高速发展&#xff0c;网络遍布全球&#xff0c;通过互联网发布的消息能快而方便的传播到世界每个角落&#xff0c;并且互联网上能传播的信息也很广&#xff0c;比如文字、图片、声音、视频等。从而&#xff0c;这种种好处使得互联网成了信息传…

【Nacos入门到实战十四】Nacos配置管理:集群部署与高可用策略

个人名片 &#x1f393;作者简介&#xff1a;java领域优质创作者 &#x1f310;个人主页&#xff1a;码农阿豪 &#x1f4de;工作室&#xff1a;新空间代码工作室&#xff08;提供各种软件服务&#xff09; &#x1f48c;个人邮箱&#xff1a;[2435024119qq.com] &#x1f4f1…

代码随想录 | Day29 | 回溯算法:电话号码的字母组合组合总和

代码随想录 | Day29 | 回溯算法&#xff1a;电话号码的字母组合&&组合总和 关于这个章节&#xff0c;大家最好是对递归函数的理解要比较到位&#xff0c;听着b站视频课可能呢才舒服点&#xff0c;可以先去搜一搜关于递归函数的讲解&#xff0c;理解&#xff0c;再开始…

黑神话悟空盘丝洞

《黑神话悟空》第四章盘丝岭地图包含盘丝洞、黄花观等地图&#xff0c;其中包含很多的隐藏要素。下面请看由“oklaoliu13”带来的《黑神话悟空》第四章全收集跑图路线指引&#xff0c;希望对大家有用。 盘丝洞1①兰喜村朱家大院&#xff08;搜刮&#xff09;→②打Boss二姐 &a…

win10服务器启动且未登录时自动启动程序

场景&#xff1a;公司服务器安装了几个程序&#xff0c;当服务器断电重启之后希望程序能自动打开&#xff0c;而不需要手动登录服务器打开。 因为软件是自己开发的所以安全方面这里没有考虑。 1.打开服务器管理器&#xff0c;点击工具&#xff0c;选择任务计划程序 2.在任务计…

OJ在线评测系统 微服务技术入门 单体项目改造为微服务 用Redis改造单机分布式锁登录

单体项目改造为微服务 什么是微服务 服务&#xff1a;提供某类功能的代码 微服务&#xff1a;专注于提供某类特定功能的代码 而不是把所有的代码放到同一个项目里 会把一个大的项目按照一定的功能逻辑进行划分 拆分成多个子模块 每个子模块可以独立运行 独立负责一类功能 …

UDP协议【网络】

文章目录 UDP协议格式 UDP协议格式 16位源端口号&#xff1a;表示数据从哪里来。16位目的端口号&#xff1a;表示数据要到哪里去。16位UDP长度&#xff1a;表示整个数据报&#xff08;UDP首部UDP数据&#xff09;的长度。16位UDP检验和&#xff1a;如果UDP报文的检验和出错&…

代码随想录--字符串--重复的子字符串

题目 给定一个非空的字符串&#xff0c;判断它是否可以由它的一个子串重复多次构成。给定的字符串只含有小写英文字母&#xff0c;并且长度不超过10000。 示例 1: 输入: "abab" 输出: True 解释: 可由子字符串 "ab" 重复两次构成。示例 2: 输入: "…

小米路由器ax1500+DDNS+公网IP+花生壳实现远程访问

有远程办公的需求&#xff0c;以及一些其他东西。 为什么写&#xff1f; ax1500路由器好像没搜到相关信息。以及其中有一点坑。 前置 公网ip Xiaomi路由器 AX1500 MiWiFi 稳定版 1.0.54 实现流程 花生壳申请壳域名https://console.hsk.oray.com/ 这里需要为域名实名认证 …

Sleuth、Zipkin学习

系列文章目录 JavaSE基础知识、数据类型学习万年历项目代码逻辑训练习题代码逻辑训练习题方法、数组学习图书管理系统项目面向对象编程&#xff1a;封装、继承、多态学习封装继承多态习题常用类、包装类、异常处理机制学习集合学习IO流、多线程学习仓库管理系统JavaSE项目员工…

【Qt】控件概述(7)—— 布局管理器

布局管理器 1. 布局管理器2. QVBoxLayout——垂直布局3. QHBoxLayout——水平布局4. QGridLayout——网格布局5. QFormLayout——表单布局6. QSpacer 1. 布局管理器 在我们之前值ui界面进行拖拽设置控件时&#xff0c;都是通过手动的控制控件的位置的。同时每个控件的位置都是…

aws(学习笔记第三课) AWS CloudFormation

aws(学习笔记第三课) 使用AWS CloudFormation 学习内容&#xff1a; AWS CloudFormation的模板解析使用AWS CloudFormation启动ec2 server 1. AWS CloudFormation 的模版解析 CloudFormation模板结构 CloudFormation是AWS的配置管理工具&#xff0c;属于Infrastructure as Co…

鸽笼原理与递归 - 离散数学系列(四)

目录 1. 鸽笼原理 鸽笼原理的定义 鸽笼原理的示例 鸽笼原理的应用 2. 递归的定义与应用 什么是递归&#xff1f; 递归的示例 递归与迭代的对比 3. 实际应用 鸽笼原理的实际应用 递归的实际应用 4. 例题与练习 例题1&#xff1a;鸽笼原理应用 例题2&#xff1a;递归…