<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>多个小球运动</title><style>canvas{border: 1px solid;}</style> </head> <body> <canvas width="500px" width="400px">对不起你的浏览器不支持canvas</canvas> <script> var mycanvas=document.querySelector('canvas'); var ctx=mycanvas.getContext('2d'); function Circle(){ this.r=Math.floor(Math.random()*20+6); this.x=Math.floor(Math.random()*(500-this.r)); this.y=Math.floor(Math.random()*(400-this.r)); this.dx=Math.floor(Math.random*10); this.dy=Math.floor(Math.random*8); this.color='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')'; } Circle.prototype.yd=function(){ this.x+=this.dx; if(this.x<=this.r){ this.dx=-this.dx }else if(this.x>=500-this.r){ this.dx=-this.dx } this.y+=this.dy; if(this.y<=this.r){ this.y=-this.dy }else if(this.y>=400-this.r){ this.dy=-this.dy } } Circle.prototype.abs=function(){ ctx.beginPath(); ctx.arc(this.x,this.y,this.r,0,2*Math.PI); ctx.fillStyle=this.color; ctx.fill(); ctx.closePath(); } var arr=[]; for(var i=0 ;i<4;i++){ arr[i]=new Circle(); } var timer=setInterval(function () { ctx.clearRect(0,0,mycanvas.width,mycanvas.height) for(var i=0;i<arr.length;i++){ arr[i].yd(); arr[i].abs(); } },40) </script> </body> </html>
老师为啥我的球显示不了
package JDBC; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.ResourceBundle; public class JdbcUtil { private static String driver; private static String jdbcUrl; private static String user; private static String password; static { //读取Properties文件 ResourceBundle bundle = ResourceBundle.getBundle("src/JDBC/jdbc"); driver = bundle.getString("driver"); jdbcUrl = bundle.getString("jdbcUrl"); user = bundle.getString("user"); password = bundle.getString("password"); try { //链接数据库 Class.forName(driver); } catch (ClassNotFoundException e) { e.printStackTrace(); } } /** * 获取Connection对象 * @return */ public static Connection getConnection(){ Connection connection = null; try { connection = DriverManager.getConnection(jdbcUrl,user,password); } catch (SQLException e) { e.printStackTrace(); } return connection; } /** * 关闭Statement * @param statement */ public static void closeStatement(Statement statement){ if(statement!=null){ try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } } } /** * 关闭Connection * @param connection */ public static void closeConnection(Connection connection){ if(connection!=null){ try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } /** * 关闭所有资源 * @param statement * @param connection */ public static void closeAll(Statement statement,Connection connection){ if(statement!=null){ try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } } if(connection!=null){ try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
package JDBC; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import static JDBC.JdbcUtil.closeAll; import static JDBC.JdbcUtil.getConnection; public class jdbcTest02 { public static void main(String[] args) { jdbcTest02 jdbcT = new jdbcTest02(); jdbcT.insertDepartments("教学部",19,19); } public void insertDepartments(String department_name,int department_id,int location_id){ Connection connection = null; Statement statement = null; try { connection = JdbcUtil.getConnection(); statement = connection.createStatement(); String sql = "insert into departments value("+department_id+",'"+department_name+"',"+location_id+")"; System.out.println(sql); statement.executeUpdate(sql); } catch (Exception e) { e.printStackTrace(); }finally { closeAll(statement, connection); } } }
老师能帮忙看一下哪里的问题嘛
before() 方法在同级前面插入元素
刚测试了在有多个同级元素时,会在每一个同级元素前添加新元素,
这种情况需要用添加属性解决嘛
这种情况下输出的内容还是没有分行。
写出最后一句print() 才会分行,请问老师这是为什么?
飞机大战副本.rar
老师,为什么我在判断飞机碰撞的if语句中加入&&plane.live后,运行时爆炸效果就不见了?
老师,请问为什么60000也不再允许范围内,但60000 可以正常输出?
这个resources文件下的那个小圆圈没有自动添加,这个手动添加太多了吧,有没有什么办法能一次性添加啊
请问老师为什么在‘r’模式里会出现空列表?
老师,这个sql注入器跟在resources文件那里写mapper.xml,哪个更常用一些?
老师,为什么创建的maven项目里面没有test文件?要怎么弄?
显示17{这里出错了,但是修改了好多次还是不对为什么,那里都好了呀
老师,这两个后面为什么都返回的是1
这是什么错误
老师,重写toString中 最后一句return sb.toString();是返回的sb字符串内容吗
老师,1楼问的那个问题“在配置文件里进行了事务的配置,不是就不用在业务层加@Transactional注解了吗?为什么这里还记呢“
请问老师,为什么不用在业务层加@Transactional注解了?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637