JS+CSS+HTML创建一个死期银行账户的类 成员变量: 账户号码 密码(加密) 存储金额(余额) 存储年限
时间: 2024-01-21 18:18:35 浏览: 57
好的,以下是一个简单的JS+CSS+HTML创建死期银行账户的类的实现:
```html
<!DOCTYPE html>
<html>
<head>
<title>死期银行账户</title>
<style>
body {
font-family: Arial, sans-serif;
}
input[type=text], input[type=password], input[type=number] {
padding: 10px;
margin: 5px;
border-radius: 5px;
border: none;
border-bottom: 2px solid #ccc;
font-size: 16px;
}
input[type=submit] {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>死期银行账户</h1>
<form>
<label for="accountNumber">账户号码:</label>
<input type="text" id="accountNumber" name="accountNumber"><br>
<label for="password">密码:</label>
<input type="password" id="password" name="password"><br>
<label for="balance">存储金额:</label>
<input type="number" id="balance" name="balance"><br>
<label for="years">存储年限:</label>
<input type="number" id="years" name="years"><br>
<input type="submit" value="创建账户">
</form>
<script>
class DeadbankAccount {
constructor(accountNumber, password, balance, years) {
this.accountNumber = accountNumber;
this.password = password;
this.balance = balance;
this.years = years;
}
}
document.querySelector('form').addEventListener('submit', function(event) {
event.preventDefault();
const accountNumber = document.querySelector('#accountNumber').value;
const password = document.querySelector('#password').value;
const balance = document.querySelector('#balance').value;
const years = document.querySelector('#years').value;
const account = new DeadbankAccount(accountNumber, password, balance, years);
console.log(account);
});
</script>
</body>
</html>
```
在上面的代码中,我们定义了一个 `DeadbankAccount` 类,其中包含了账户号码、密码、存储金额和存储年限等成员变量。在创建账户时,我们通过表单获取用户输入的值,然后使用这些值创建一个新的 `DeadbankAccount` 实例,并将其打印到控制台中。
阅读全文