实体类
import java.util.*;
public class DVD
{
static Scanner sc=new Scanner(System.in);
public static String DVD[]={"罗马假日","浪漫书屋","越狱"};
static String DVDname;;
public static void LookDVD()//查看DVD
{
for(int i=0;i<DVD.length;i++)
{
System.out.println(DVD[i]);
}
}
public static void loanDVD()//借出DVD
{
System.out.println("请输入DVD名称");
DVDname=sc.next();
for(int i=0;i<DVD.length;i++)
{
if(DVD[i].equals(DVDname))
{
DVD[i]="已借出:"+DVD[i];
}
}
System.out.println("操作成功");
}
public static void huan()
{
System.out.println("请输入要还的DVD名称:");
String name=sc.next();
for(int i=0;i<DVD.length;i++)
{
if(DVD[i].equals("已借出:"+name))
{
DVD[i]=DVD[i].substring(4);
}
}
System.out.println("操作成功");
}
}
测试类
import java.util.Scanner;
public class test
{
public static void main(String[] args)
{
do{
Scanner sc=new Scanner(System.in);
System.out.println("-----------------------------");
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("-----------------------------");
System.out.print("请选择:");
int a=sc.nextInt();
switch(a)
{
case 1: DVD.LookDVD();break;
case 2: DVD.loanDVD();break;
case 4: DVD.huan();break;
}
if(a==3)
{
System.out.println("-----欢迎使用-----");
break;
}
System.out.println("输入o返回,重新选择");
String c=sc.next();
if(c.equals("o"))
{
}
else
{
break;
}
}while(true);
}
}
import java.util.*;
public class DVD
{
static Scanner sc=new Scanner(System.in);
public static String DVD[]={"罗马假日","浪漫书屋","越狱"};
static String DVDname;;
public static void LookDVD()//查看DVD
{
for(int i=0;i<DVD.length;i++)
{
System.out.println(DVD[i]);
}
}
public static void loanDVD()//借出DVD
{
System.out.println("请输入DVD名称");
DVDname=sc.next();
for(int i=0;i<DVD.length;i++)
{
if(DVD[i].equals(DVDname))
{
DVD[i]="已借出:"+DVD[i];
}
}
System.out.println("操作成功");
}
public static void huan()
{
System.out.println("请输入要还的DVD名称:");
String name=sc.next();
for(int i=0;i<DVD.length;i++)
{
if(DVD[i].equals("已借出:"+name))
{
DVD[i]=DVD[i].substring(4);
}
}
System.out.println("操作成功");
}
}
测试类
import java.util.Scanner;
public class test
{
public static void main(String[] args)
{
do{
Scanner sc=new Scanner(System.in);
System.out.println("-----------------------------");
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("-----------------------------");
System.out.print("请选择:");
int a=sc.nextInt();
switch(a)
{
case 1: DVD.LookDVD();break;
case 2: DVD.loanDVD();break;
case 4: DVD.huan();break;
}
if(a==3)
{
System.out.println("-----欢迎使用-----");
break;
}
System.out.println("输入o返回,重新选择");
String c=sc.next();
if(c.equals("o"))
{
}
else
{
break;
}
}while(true);
}
}