java求助 英文好的来,Define a class called PoliceDatabase with the following instance variables://这个Arraylist 不会写 CLASS 类vehicles,drivers,infractions 都写好了.vehicles – an ArrayList storing all vehicles in the databasedrivers

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/23 15:49:52
java求助英文好的来,DefineaclasscalledPoliceDatabasewiththefollowinginstancevariables://这个Arraylist不会写CLASS类

java求助 英文好的来,Define a class called PoliceDatabase with the following instance variables://这个Arraylist 不会写 CLASS 类vehicles,drivers,infractions 都写好了.vehicles – an ArrayList storing all vehicles in the databasedrivers
java求助 英文好的来,
Define a class called PoliceDatabase with the following instance variables:
//这个Arraylist 不会写 CLASS 类vehicles,drivers,infractions 都写好了.
vehicles – an ArrayList storing all vehicles in the database
drivers – an ArrayList storing all drivers (i.e., people who drive vehicles) in the database
infractions – an ArrayList storing all infractions that have ever been given to drivers
Write the following interesting methods:
//下面这些看不太懂,麻烦高手教下怎么写.
a zero-parameter constructor that initializes all the ArrayLists properly
registerDriver(Driver aDriver) which takes a Driver object as a parameter and then registers (i.e., remembers for later) the driver in the database.
registerVehicle(Vehicle aVehicle, String license) which takes a vehicle object as a parameter and the license ID of a driver who owns the vehicle and then registers the vehicle in the database by updating the vehicles list accordingly as well as storing the vehicle’s owner properly.
unregisterVehicle(String plate) which takes a vehicle’s plate as a parameter and then removes the vehicle from the database by updating the vehicles list accordingly.
reportStolen(String plate) records that the vehicle with the given plate number has been stolen.
changeOwner(String plate, String license) which updates the database by changing the owner information for the vehicle with the given plate to the driver with the given license ID.

java求助 英文好的来,Define a class called PoliceDatabase with the following instance variables://这个Arraylist 不会写 CLASS 类vehicles,drivers,infractions 都写好了.vehicles – an ArrayList storing all vehicles in the databasedrivers
大致写了下:
package com.lwx.temp;
public class Driver {
private String license;
public String getLicense() {
return license;
}
public void setLicense(String license) {
this.license = license;
}
}

/**
*
* 假设数据库中表如下:
*
* table_driver(license)
* table_vehicle(plate, license, status)
*
*
*/
package com.lwx.temp;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.ArrayList;
public class PoliceDatabase{
Connection conn;
ArrayList vehicles;
ArrayList drivers;
ArrayList infractions;

public PoliceDatabase(){
//zero-parameter constructor 无参数构造器
vehicles = new ArrayList();
drivers = new ArrayList();
infractions = new ArrayList();
// registerDriver 注册数据库驱动,假设是MySQL数据库
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/数据库名称", "用户名", "密码");

//下面就可以进行初始化 vehicles/drivers/infractions 这3个ArrayList
// 代码就不详细写了...

}catch(Exception e){
e.printStackTrace();
}
}

public void registerDriver(Driver aDriver){
String sql = "insert into table_driver(license) values('" + aDriver.getLicense()+ "')";
executeSql(sql);
}

public void registerVehicle(Vehicle aVehicle, String license) {
String sql = "insert into table_vehicle(plate,license,status) values('" + aVehicle.getPlate()+ "','" + license + "','')";
executeSql(sql);
}

public void unregisterVehicle(String plate) {
String sql = "delete from table_vehicle where plate='" + plate + "'";
executeSql(sql);
}

public void reportStolen(String plate){
String sql = "update table_vehicle set status='STOLEN' where plate='" + plate + "'" ;
executeSql(sql);
}

public void changeOwner(String plate, String license){
String sql = "update table_vehicle set license='" + license + "' where plate='" + plate + "'" ;
executeSql(sql);
}

private void executeSql(String sql){
try{
Statement stmt = conn.createStatement();
stmt.execute(sql);
stmt.close();
}catch(Exception e){
e.printStackTrace();
}
}

}

java求助 英文好的来,Define a class called PoliceDatabase with the following instance variables://这个Arraylist 不会写 CLASS 类vehicles,drivers,infractions 都写好了.vehicles – an ArrayList storing all vehicles in the databasedrivers 在JAVA中assignment的意思Assignment 这个词在JAVA中是什么意思?例如:Define the concept:assignment (x = y) 求助一位英语好的大神,翻译一篇英文材料 基于JAVA的人事管理系统翻译成英文. 求助“经典”的英文译音! 求助~~~攀岩 的英文是什么? 求助英文好的同学,八九十个词,最好自己写啊! 求助英语翻译“在我来的那一天,你就应该安排好计划”谢谢! 基于JAVA的人事管理系统设计与实现的英文意思 EXT 的 Ext.define cp是哪个英文的缩写啊这个,别人问我.我说不上来,只好来求助了. #define 关于group work的英文解释 ///define of group work 回答的时候留个内容出处,全文:Clearly define the concept of group work 帮忙看一下,这句英文怎么写?我用java语言编写了一个程序,名字叫myApp,我英文标注一下,证明软件是java编写的,应该是myApp for java 还是myApp by java 还是其他写法? 请帮忙回答:How do you define global mindset?How do you define global mindset?面试要用的,长度适中就好,急, 《my favourite tea》英语作文求助!什么地方拉来的或者自己写的快点传上来!好的话重赏! 翻译一个英文照片,英语好的来. 大家来推荐一下好的英文纪录片