我试图以一种方式移动一个对象,使其旋转方向与鼠标单击的方向相同,并移动到鼠标单击的位置.到目前为止,我安排了运动,但我认为角度有问题,因为它不像我那样旋转.我哪里弄错了?我该如何解决?
var theThing = document.querySelector("#thing");
var container = document.querySelector("#contentContainer");
var triangle = document.querySelector("#triangle");
container.addEventListener("click", getClickPosition, false);
function getClickPosition(e) {
var xPosition = e.clientX;
var yPosition = e.clientY;
var translate3dValue = "translate3d(" + xPosition + "px," + yPosition +
"px,0)";
var spx = document.querySelector("#triangle").clientWidth / 2;
var spy = document.querySelector("#triangle").clientHeight / 2;
var angle = Math.atan2(yPosition - spy, xPosition - spx) * 180 /
Math.PI;
if (angle < 0) {
angle = 360 - (-angle);
}
theThing.style.transform = translate3dValue;
theThing.style.transform += …Run Code Online (Sandbox Code Playgroud)我试图将名称,哈希密码,盐和哈希类型插入数据库.唯一改变的是参数的类型.我相信它可以更有效地完成.如何避免使用重载?我需要使用泛型吗?谢谢.
InsertMethods
protected void insert(String name, String secretpassword, String salt, String type)
{
String sql = "INSERT INTO login(username,password,salt,type) VALUES(?,?,?,?)";
try (Connection conn = this.connect();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, name);
pstmt.setString(2, secretpassword);
pstmt.setString(3, salt);
pstmt.setString(4, type);
pstmt.executeUpdate();
System.out.println("Successful");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
protected void insert(String name, byte[] secretpassword, String salt, String type)
{
String sql = "INSERT INTO login(username,password,salt,type) VALUES(?,?,?,?)";
try (Connection conn = this.connect();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, name);
pstmt.setString(2, Arrays.toString(secretpassword)); …Run Code Online (Sandbox Code Playgroud)