日期:2014-05-20 浏览次数:20912 次
package dvd;
public class DVD {
public String[]name ={};//DVD名字
public boolean []flag={};//DVD借出状态
public int []index={};
public String[] str = {} ;
}package dvd;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class DVDManager {
DVD d = new DVD();
Scanner input = new Scanner(System.in);
public int j;
public void show(){
System.out.println("欢迎使用迷你DVD管理器");
System.out.println("---------------------------------------------");
System.out.println("1.新增DVD");
System.out.println("2.查看DVD");
System.out.println("3.删除DVD");
System.out.println("4.借出DVD");
System.out.println("5.归还DVD");
System.out.println("6.排行榜");
System.out.println("7.退出");
System.out.println("---------------------------------------------");
System.out.print("请选择:");
while(!input.hasNextInt()){
System.out.println("您输入的不是整数,请重新输入:");
String str = input.next();
}
int i = input.nextInt();
switch(i){
case 1:
System.out.println("-->新增DVD");
addDVD();
backMenu();
System.out.println("******************************");
break;
case 2:
System.out.println("-->查看DVD");
seeDVD();
backMenu();
System.out.println("******************************");
break;
case 3:
System.out.println("-->删除DVD");
deleteDVD();
backMenu();
System.out.println("******************************");
break;
case 4:
System.out.println("-->借出DVD");
lendDVD();
backMenu();
System.out.println("******************************");
break;
case 5:
System.out.println("-->归还DVD");
returnDVD();
backMenu();
System.out.println("******************************");
break;
case 6:
System.out.println("-->排行榜");
rankList();
backMenu();
System.out.println("******************************");
break;
case 7:
return;
default :
while(i<1||i>7){
System.out.println("您输入的不是1-7整数,请重新输入");
i = input.nextInt();
}
break;
}
}
public void enlargeLength(){
String[]name1 =new String[d.name.length+1];
System.out.println(name1.length);
System.arraycopy(d.name, 0, name1, 0, d.name.length);
d.name= name1;
boolean []flag1 = new boolean[d.flag.length+1];
System.arraycopy(d.flag, 0, flag1, 0, d.flag.length);
d.flag =flag1;
String[]str1 =new String[d.str.length+1];
System.arraycopy(d.str, 0, name1, 0,d.str.length);
d.str= str1;
}
public void cutLength(int i){
String []name1 = new String[d.name.length-1];
System.arraycopy(d.name, 0, name1, 0, i+1);
System.arraycopy(d.name, i+1, name1, i, name1.length-i);
d.name =name1;
boolean []flag1 = new boolean[d.flag.length-1];
System.arraycopy(d.flag, 0,flag1, 0, i+1);
System.arraycopy(d.flag, i+1, flag1, i, flag1.length-i);
d.flag =flag1;
String []str1 = new String[d.str.length-1];