JAVA 作业 急急急

来源:百度知道 编辑:UC知道 时间:2024/07/12 14:11:24
1。该类名称 Device;
2。需要提供四个方法 ;
void Record(String filename)
void StopRecord()
void Play(String filename)
void StopPlay()
3。方法的实现仅仅是将屏幕打印相关信息即可;

难度:
方法void Play(String filename)中的参数filename可以是多个文件的列表,之间使用“;”隔开,
因此该函数需要提取该参数的具体每个文件名,也一并将之答应到屏幕上。
题目: 创建抽象类及其实现类2009-03-24 15:35要求:

1。类名称 Device, PrintDevice, FileDevice;
2。抽象类Device提供四个方法 ;
void Record(String filename)
void StopRecord()
void Play(String filename)
void StopPlay()
3。PrintDevice的方法实现向屏幕打印相关信息;
4。FileDevice的方法实现向文件写入相关信息;

public class Device {
public void Record(String filename)
{

}
void stopRecord()
{
}

void play(String filename){

System.out.println("play called!");

if(!filename.contains(";")){
System.out.println(filename);
}
else {
String[] temp = filename.split(";");
for(int i = 0; i<temp.length;i++){
System.out.println(temp[i]);
}
}

}
void stopPlay() {

}

static public void main(String[] temp){
Device d=new Device();
d.play("A;B;C");
}

}

class Device{
private String[] file;
public void Record(String filename){
}
void stopRecord(){
}
void play(String filename){
String[] str=filename.split(";");
for(int i=0;i<str.length;i++)
System.out.println