<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>动画小球</title> <style> canvas{ border: 1px solid; width: 400px; height: 300px; } </style> </head> <body> <canvas>您的浏览器不支持canvas标签</canvas> <script> let mycanvas = document.querySelector('canvas'); let ctx = mycanvas.getContext('2d'); let x=50; let y=50; let speed=-1; let speedY=2; let timer=setInterval(function () { ctx.clearRect(0,0,mycanvas.width,mycanvas.height); x+=speed; if(x<=20){ speed=Math.abs(speed); }else if(x>=380){ speed=-speed; } y+=speedY; if(y>=280){ speedY=-speedY; }else if(y<=20){ speedY=-speedY; } ctx.beginPath(); ctx.arc(x,y,20,0,2*Math.PI); ctx.fillStyle='skyblue'; ctx.fill(); ctx.closePath(); },30); </script> </body> </html>
为什么写在style标签里面的width=400px和height=300px,小球就没有按实际的大小来跳动,放canvas标签里面就不会,我看语法也没有写错啊!
老师,这个用户名和密码是输哪里的用户名?
老师,这个报错是哪里的问题(找不到错5555)
package DataBase; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class test { public void insertDepartments(String department_name,int location_id) { Connection conn=null; Statement state=null; try { //注册驱动 Class.forName("com.mysql.jdbc.driver"); //创建链接,解决乱码问题useUnicode=true&characterEncoding=utf-8 conn=DriverManager.getConnection("jdbc:mysql://localhost:3306?useUnicode=true&characterEncoding=utf-8", "root", "root"); String sql="insert into department values(default,'"+department_name+"',"+location_id+")"; //注意不要导错包,使用javasql包下 state=conn.createStatement(); int flag=state.executeUpdate(sql); System.out.println(flag); //注意释放statement(先)和connection(后) } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally { if(state!=null) { try { state.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(conn!=null) { try { conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } public static void main(String[] args) { test test=new test(); test.insertDepartments("研发部", 8); } }
老师,System.out.println(“半径”+d);//d是double型。+号两边不是都应该是字符串型吗,那么d不应该强制转型为String类型才可以吗
老师,我把项目删除后重新创建项目,就只剩下这些目录了
工厂模式.png
老师,为什么在这里BYD类的代码也打印出来了?
下载不了requests,和视频上的怎么不一样
老师 函数能在查询条件里直接使用么,还是只能在select后面使用
23. 求平均薪水是 2000 以上的部门
select deptno from emp where aver(sal)>2000
请问为什么不行,如果是权限的问题已经设置过了却还不行。怎么办
老师问一下,为什么start=time.time()不可以写成
start=time(),是语法问题吗
老师下面运行结果显示的是什么?看不懂,他为什么不显示内容
老师报错了,该怎么办?
想问问请求市区数据里边最后setState的具体作用,
函数里边看着就是处理请求获得到的数据,好像没有对state里的options有什么改动,
试过注释掉进行操作,需要点击俩下才能显示市区的信息,然后最后一个区节点点击会报错,
还是说这步操作就是简单的state更新?
class ManTou{ private int id; public ManTou(int id) { this.id = id; } public int getId() { return id; } public void setId(int id) { this.id = id; } } class Buffer{ private ManTou[] container=new ManTou[10];//存储馒头的容器 private int index=0; //下面定义一个存储馒头的方法 public synchronized void push(ManTou manTou){ //为了防止馒头存满了额外添加一个方法来判断 while (this.index==this.container.length){//使用while循环是为了增加代码的可判断性 //下面实现了一个方法wait等待 try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } //下面添加一个方法用来唤醒 this.notify(); this.container[this.index]=manTou;//向容器中存放馒头 index++;//上一个位置存放过以后换到下一个位置存放 } //下面定义一个方法来取馒头 public synchronized ManTou qv(){ while (this.index==0){ try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } //因为上面加过了这里减一次取相应位置的馒头 this.notify(); this.index--; return this.container[this.index]; } } //下面创建一个生产线程 class Shengchan extends Thread{ private Buffer b; public Shengchan(Buffer b){ this.b=b; } @Override public void run() { for(int i=0;i<10;i++){ ManTou m=new ManTou(i); this.b.push(m); System.out.println("生产了馒头编号"+m.getId()); } } } //下面创建一个消费馒头的线程 class XiaoFei extends Thread{ private Buffer b; public XiaoFei(Buffer b){ this.b=b; } @Override public void run() { for(int i=0;i<10;i++){ ManTou qv = this.b.qv(); System.out.println("消费馒头"+qv.getId()); } } } public class TestManTou { public static void main(String[] args) { Buffer b=new Buffer(); new Shengchan(b).start(); new XiaoFei(b).start(); } }
怎么没有生产就开始消费了,感觉代码也没有什么问题
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637