學生管理系統(HashSet實現和資料庫實現)

2021-10-06 08:40:03 字數 4001 閱讀 5249

主函式:

public

class

testone

}static

void

menu()

set.

add(student)

; system.out.

println

(set.

size()

);system.out.

println

("新增成功");

break;}

case2:

system.out.

println

("沒有找到該學號的學生資訊,刪除失敗!!!");

break;}

case3:

for(student stu : set)

}break;}

case4:

for(student stu : set)

}break;}

default

: system.out.

println

("i'm sorry,there is not the "

+option+

" option,please try again.");

}}}

學生類:

public

class

student

public

void

setid

(string id)

public string getname()

public

void

setname

(string name)

public string getmobile()

public

void

setmobile

(string mobile)

public string getaddress()

public

void

setaddress

(string address)

@override

public

inthashcode()

@override

public

boolean

equals

(object obj)

return

false;}

@override

public string tostring()

}

主函式:

public

class

main

}static

void

menu()

system.out.

println

("請輸入學生姓名:");

string name = scanner.

next()

; system.out.

println()

; string mobile = scanner.

next()

; system.out.

println()

; string address = scanner.

next()

; string sql1 =

"insert into student (id,name,mobile,address) values ('"

+ id +

"','"

+ name +

"','"

+ mobile +

"','"

+address+

"')";if

(db.

update

(sql1)

) system.out.

println

("學生資訊新增成功!!");

else

system.out.

println

("新增失敗!!!");

break;}

case2:

else

break;}

case3:

system.out.

println

("請輸入修改的學生姓名:");

string name = scanner.

next()

; system.out.

println()

; string mobile = scanner.

next()

; system.out.

println()

; string address = scanner.

next()

; string sql =

"update student set name = '"

+name+

"',mobile = '"

+mobile+

"',address = '"

+address+

"'where id = '"

+id+

"'";

if(db.

update

(sql)

)else

break;}

case4:

new()}

catch

(sqlexception e)}}

; db.

select

;break;}

default

: system.out.

println

("i'm sorry,there is not the "

+option+

" option,please try again.");

}}}

資料庫連線自定義類:

public

class

dblink

catch

(exception e)

return null;

}public

boolean

update

(string sql)

catch

(exception e)

finally

return

false;}

public

void

select

catch

(exception e)

finally

}public

boolean

exist

(string sql)

catch

(exception e)

finally

return

false;}

//方法的過載

private

void

close

(resultset resultset,statement statement,connection connection)

catch

(sqlexception e)

close

(statement,connection);}

private

void

close

(statement statement,connection connection)

catch

(sqlexception e)

trycatch

(sqlexception e)

}}

介面:

public

inte***ce

HashSet集合學生管理系統

private static hashset set newhashset public static void main string args 選單方法 private static void menu system.out.println 請輸入名字 student.setname sc.ne...

學生管理系統(陣列實現)

標頭檔案 ifndef student h define student h define n 100 struct student typedef struct student st void welcome void show int input st stu void display st s...

PHP 學生管理系統實現

最近學校開了php課程,順便寫了個作業,分享一下吧。都是很簡單的東西,新手用得著 省略部分前端 首先是登入的校驗 session start user post username pass post password session user user enter post login undo 管...