采用JAVA设计一个小型图书管理程序(只要增删查改) 30
采用JAVA设计一个小型图书管理程序,具有信息添加、查询、修改和删除功能。图书信息包括:图书编号,书名,作者名,分类号,出版单位,出版时间,价格。用eclipse编写然后...
采用JAVA设计一个小型图书管理程序,具有信息添加、查询、修改和删除功能。图书信息包括: 图书编号,书名,作者名,分类号,出版单位,出版时间,价格。
用eclipse编写然后连接到数据库,能正常运行出现图形用户界面实现增删查改四个功能就行了,谢谢了,可以发到我邮箱2194215481@qq.com。 展开
用eclipse编写然后连接到数据库,能正常运行出现图形用户界面实现增删查改四个功能就行了,谢谢了,可以发到我邮箱2194215481@qq.com。 展开
4个回答
展开全部
使用java语言设计一款小型图书管理系统,能够通过主界面根据关键字查询图书信息,能够添加图书信息和删除过去图书信息
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
私信我 我或许可以完成哦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以做,要的话,私信
追问
私了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/**
*
*/
package com.java.lanqiao.action;
/**
* @author mayj
*Title:Demo
*date:2017年12月14日 下午12:51:41
*/
import java.util.Random;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Book b = new Book();
b.init();
b.menu();
}
}
class Book{
private String bookName;
private String bookState;
private int bookNums;
private int bookPrice;
static int count = 0;
Book(){}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getBookState() {
return bookState;
}
public void setBookState(String bookState) {
this.bookState = bookState;
}
public int getBookNums() {
return bookNums;
}
public void setBookNums(int bookNums) {
this.bookNums = bookNums;
}
public int getBookPrice() {
return bookPrice;
}
public void setBookPrice(int bookPrice) {
this.bookPrice = bookPrice;
}
Book[] book = new Book[10];
Scanner in = new Scanner(System.in);
Random r = new Random();
public void init(){
for (int i = 0; i < 3; i++) {
book[i] = new Book();
}
/*System.out.println();
for (int i = 0; i < 3; i++) {
book[i].bookName = in.next();
}*/
book[0].bookName = "aaa";
book[1].bookName = "sss";
book[2].bookName = "ddd";
for (int i = 0; i < 3; i++) {
book[i].bookNums = r.nextInt(10)+1;
count ++;
}
for (int i = 0; i < 3; i++) {
book[i].bookState = "在库";
}
for (int i = 0; i < 3; i++) {
book[i].bookPrice = r.nextInt(50)+30;
}
}
public void lookBook(){
System.out.println("\n书名 库存 价格 状态");
for (int i = 0; i < count; i++) {
System.out.println(book[i].bookName+" "+book[i].bookNums+" "+book[i].bookPrice+" "+book[i].bookState);
}
}
public void addBook(){
String name;
Book newBook = new Book();
System.out.print("请输入书名:");
name = in.next();
newBook.bookName = name;
book[count] = newBook;
book[count].bookName = newBook.bookName;
book[count].bookState = "在库";
book[count].bookNums = r.nextInt(10)+1;
book[count].bookPrice = r.nextInt(50)+30;
count ++;
System.out.println("添加成功!!!");
lookBook();
}
public void deleteBook(){
System.out.print("请输入需要删除的图书:");
String name;
name = in.next();
for (int i = 0; i < count; i++) {
if( book[i].bookName.equals(name) ){
if(book[i].bookState.equals("在库")){
count --;
int index = i;
while(book[index+1] != null){
book[index] = book[index+1];
index ++;
}
System.out.println("删除成功!!!");
break;
}else{
System.out.println("该图书不在馆内,不能删除");
}
}else if(!book[i].bookName.equals(name)){
System.out.println("没有找到"+name+"这本书!!!");
}
}
lookBook();
}
public void lendBook(){
System.out.print("请输入要借阅的图书名称:");
String naem = in.next();
for (int i = 0; i < count; i++) {
if( book[i].bookName.equals(naem) && book[i].bookNums > 0){
System.out.println("借书成功!!!");
book[i].bookNums --;
break;
}
else{
System.out.println("你想借阅的书不在书库内!!!");
}
}
lookBook();
}
public void returnBook(){
System.out.print("请输入需要归还的图书名称:");
String naem = in.next();
for (int i = 0; i < count; i++) {
if( book[i].bookName.equals(naem)){
System.out.println("还书成功!!!");
book[i].bookNums ++;
break;
}
else{
System.out.println("该书不是书库内的书,还书失败!!!");
}
}
lookBook();
}
public void modifyBook(){
System.out.print("请输入要修改图书的图书名称:");
String name = in.next();
System.out.print("请输入要修改图书的图书状态:");
String status = in.next();
System.out.print("请输入要修改图书的图书数量:");
int nums = in.nextInt();
System.out.print("请输入要修改图书的图书价格:");
int price = in.nextInt();
for (int i = 0; i < count; i++) {
if(book[i].bookName.equals(name)){
book[i].bookState = status;
book[i].bookNums = nums;
book[i].bookPrice = price;
System.out.println("图书信息修改成功!!!");
break;
}else{
System.out.println("修改失败!!!");
}
}
lookBook();
}
public void rank(){
Book temp = new Book();
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
if(book[i].bookNums < book[j].bookNums){
temp = book[i];
book[i] = book[j];
book[j] = temp;
}
}
}
lookBook();
}
public void menu(){
Scanner in = new Scanner(System.in);
String s = null;
do{
System.out.println("\n---------------- 图书管理系统 ----------------\n");
System.out.println(" 1 查看图书");
System.out.println(" 2 增加图书");
System.out.println(" 3 删除图书");
System.out.println(" 4 借阅图书");
System.out.println(" 5 归还图书");
System.out.println(" 6 修改图书");
System.out.println(" 7 图书排行");
System.out.println(" 0 退出系统");
System.out.print("\n请输入你的选择:");
int n = in.nextInt();
switch (n) {
case 1:
lookBook();
break;
case 2:
addBook();
break;
case 3:
deleteBook();
break;
case 4:
lendBook();
break;
case 5:
returnBook();
break;
case 6:
modifyBook();
break;
case 7:
rank();
break;
case 0:
System.exit(0);
break;
default:
System.out.println("输入有误!!!");
break;
}
System.out.println("\n是否继续 ? ( y / n)");
s = in.next();
}while(s.equals("y") || s.equals("Y"));
}
}
*
*/
package com.java.lanqiao.action;
/**
* @author mayj
*Title:Demo
*date:2017年12月14日 下午12:51:41
*/
import java.util.Random;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Book b = new Book();
b.init();
b.menu();
}
}
class Book{
private String bookName;
private String bookState;
private int bookNums;
private int bookPrice;
static int count = 0;
Book(){}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getBookState() {
return bookState;
}
public void setBookState(String bookState) {
this.bookState = bookState;
}
public int getBookNums() {
return bookNums;
}
public void setBookNums(int bookNums) {
this.bookNums = bookNums;
}
public int getBookPrice() {
return bookPrice;
}
public void setBookPrice(int bookPrice) {
this.bookPrice = bookPrice;
}
Book[] book = new Book[10];
Scanner in = new Scanner(System.in);
Random r = new Random();
public void init(){
for (int i = 0; i < 3; i++) {
book[i] = new Book();
}
/*System.out.println();
for (int i = 0; i < 3; i++) {
book[i].bookName = in.next();
}*/
book[0].bookName = "aaa";
book[1].bookName = "sss";
book[2].bookName = "ddd";
for (int i = 0; i < 3; i++) {
book[i].bookNums = r.nextInt(10)+1;
count ++;
}
for (int i = 0; i < 3; i++) {
book[i].bookState = "在库";
}
for (int i = 0; i < 3; i++) {
book[i].bookPrice = r.nextInt(50)+30;
}
}
public void lookBook(){
System.out.println("\n书名 库存 价格 状态");
for (int i = 0; i < count; i++) {
System.out.println(book[i].bookName+" "+book[i].bookNums+" "+book[i].bookPrice+" "+book[i].bookState);
}
}
public void addBook(){
String name;
Book newBook = new Book();
System.out.print("请输入书名:");
name = in.next();
newBook.bookName = name;
book[count] = newBook;
book[count].bookName = newBook.bookName;
book[count].bookState = "在库";
book[count].bookNums = r.nextInt(10)+1;
book[count].bookPrice = r.nextInt(50)+30;
count ++;
System.out.println("添加成功!!!");
lookBook();
}
public void deleteBook(){
System.out.print("请输入需要删除的图书:");
String name;
name = in.next();
for (int i = 0; i < count; i++) {
if( book[i].bookName.equals(name) ){
if(book[i].bookState.equals("在库")){
count --;
int index = i;
while(book[index+1] != null){
book[index] = book[index+1];
index ++;
}
System.out.println("删除成功!!!");
break;
}else{
System.out.println("该图书不在馆内,不能删除");
}
}else if(!book[i].bookName.equals(name)){
System.out.println("没有找到"+name+"这本书!!!");
}
}
lookBook();
}
public void lendBook(){
System.out.print("请输入要借阅的图书名称:");
String naem = in.next();
for (int i = 0; i < count; i++) {
if( book[i].bookName.equals(naem) && book[i].bookNums > 0){
System.out.println("借书成功!!!");
book[i].bookNums --;
break;
}
else{
System.out.println("你想借阅的书不在书库内!!!");
}
}
lookBook();
}
public void returnBook(){
System.out.print("请输入需要归还的图书名称:");
String naem = in.next();
for (int i = 0; i < count; i++) {
if( book[i].bookName.equals(naem)){
System.out.println("还书成功!!!");
book[i].bookNums ++;
break;
}
else{
System.out.println("该书不是书库内的书,还书失败!!!");
}
}
lookBook();
}
public void modifyBook(){
System.out.print("请输入要修改图书的图书名称:");
String name = in.next();
System.out.print("请输入要修改图书的图书状态:");
String status = in.next();
System.out.print("请输入要修改图书的图书数量:");
int nums = in.nextInt();
System.out.print("请输入要修改图书的图书价格:");
int price = in.nextInt();
for (int i = 0; i < count; i++) {
if(book[i].bookName.equals(name)){
book[i].bookState = status;
book[i].bookNums = nums;
book[i].bookPrice = price;
System.out.println("图书信息修改成功!!!");
break;
}else{
System.out.println("修改失败!!!");
}
}
lookBook();
}
public void rank(){
Book temp = new Book();
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
if(book[i].bookNums < book[j].bookNums){
temp = book[i];
book[i] = book[j];
book[j] = temp;
}
}
}
lookBook();
}
public void menu(){
Scanner in = new Scanner(System.in);
String s = null;
do{
System.out.println("\n---------------- 图书管理系统 ----------------\n");
System.out.println(" 1 查看图书");
System.out.println(" 2 增加图书");
System.out.println(" 3 删除图书");
System.out.println(" 4 借阅图书");
System.out.println(" 5 归还图书");
System.out.println(" 6 修改图书");
System.out.println(" 7 图书排行");
System.out.println(" 0 退出系统");
System.out.print("\n请输入你的选择:");
int n = in.nextInt();
switch (n) {
case 1:
lookBook();
break;
case 2:
addBook();
break;
case 3:
deleteBook();
break;
case 4:
lendBook();
break;
case 5:
returnBook();
break;
case 6:
modifyBook();
break;
case 7:
rank();
break;
case 0:
System.exit(0);
break;
default:
System.out.println("输入有误!!!");
break;
}
System.out.println("\n是否继续 ? ( y / n)");
s = in.next();
}while(s.equals("y") || s.equals("Y"));
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询