主题:高手帮忙看看问题在那里,救命稻草!
这是一个图片的constructor,任何帮助不胜感激,
import java.io.*;
public class Picture
{
private int NumberTags=0;
private String Title,picPath;
private String[] Tags;
public Picture(java.io.File pictureFile){
picPath=pictureFile;
Title="";
}
public Picture(java.io.File pictureFile,String title){
picPath=pictureFile;
Title=title;}
public boolean addTag(String tag){
String[] Tags=tag;
for(int i=0;i<Tags.length;i++){
if (Tags[i]==tag)
return false;
return true;
}
public void clearTags();
{
Tags=null;
}
public int getNumberTags(){
if (Tags.Picture=null)
NumberTags=0;
else {NumberTags=Tags.length;}
return NumberTags;
}
public java.io.File getPictureFile(){
return picPath;}
public String[] getTags(){
//tags array grows as the i >10
Tags=new Tags[10];
if (NumberTags==Tags.length)
increseSize();
Tags[NumberTags]= new File(Title,Tags);
NumberTags++;
return;
}
private void increaseSize(){
Tags[] temp=new Tags[Tags.length*2];
for (int i=0 ;i<NUmberTags.length;i++)
temp[i]=Tags[i];
Tags=temp;
}
public String toString()
{for (int i=0;i<Tags.length;i++)
{System.out.println (Tags[i]);
System.out.print(" ");
return;}
}
public String getTitle(){
return Title;
}
public boolean removeTag(String tag){
for(int i=0;i<Tags.length;i++)
if (Tags[i].equalsIgnoreCase(tag)){
Tags[i]=null;
return true;
}
return false;
}
public void setTitle(String title){
Title=title;
}
public boolean hasTag(String tag){
for(int i=0;i<Tags.length;i++)
if(Tags[i].equalsIgnoreCase(tag) && !tag=null)
{return true;}
else{ return false;}
}
public boolean hasTags(String tag){
return result=helper(Tags.Picture,Tags.length);
private boolean helper(String[] Tags, int n);
boolean result;
if (n < 1){
result = false;
}
else{
helper=helper(Tags,n-1);
if(Tags[n-1].equalsIgnoreCase(tag)&&tag!=null)
result=true;}
另一个问题
如何定义writer 啊?
import java.io.*;
import java.util.*;
public class CollectionWriter{
private CollectionLoader collectionLoader;
public CollectionWriter(){
CollectionLoader=CollectionLoader();
}
public CollectionLoader getCorrespondLoader(){
return CollectionLoader;
}
public void save(PictureCollection collection,java.io.File path) throws java.io.IOException{
}
[em10]
import java.io.*;
public class Picture
{
private int NumberTags=0;
private String Title,picPath;
private String[] Tags;
public Picture(java.io.File pictureFile){
picPath=pictureFile;
Title="";
}
public Picture(java.io.File pictureFile,String title){
picPath=pictureFile;
Title=title;}
public boolean addTag(String tag){
String[] Tags=tag;
for(int i=0;i<Tags.length;i++){
if (Tags[i]==tag)
return false;
return true;
}
public void clearTags();
{
Tags=null;
}
public int getNumberTags(){
if (Tags.Picture=null)
NumberTags=0;
else {NumberTags=Tags.length;}
return NumberTags;
}
public java.io.File getPictureFile(){
return picPath;}
public String[] getTags(){
//tags array grows as the i >10
Tags=new Tags[10];
if (NumberTags==Tags.length)
increseSize();
Tags[NumberTags]= new File(Title,Tags);
NumberTags++;
return;
}
private void increaseSize(){
Tags[] temp=new Tags[Tags.length*2];
for (int i=0 ;i<NUmberTags.length;i++)
temp[i]=Tags[i];
Tags=temp;
}
public String toString()
{for (int i=0;i<Tags.length;i++)
{System.out.println (Tags[i]);
System.out.print(" ");
return;}
}
public String getTitle(){
return Title;
}
public boolean removeTag(String tag){
for(int i=0;i<Tags.length;i++)
if (Tags[i].equalsIgnoreCase(tag)){
Tags[i]=null;
return true;
}
return false;
}
public void setTitle(String title){
Title=title;
}
public boolean hasTag(String tag){
for(int i=0;i<Tags.length;i++)
if(Tags[i].equalsIgnoreCase(tag) && !tag=null)
{return true;}
else{ return false;}
}
public boolean hasTags(String tag){
return result=helper(Tags.Picture,Tags.length);
private boolean helper(String[] Tags, int n);
boolean result;
if (n < 1){
result = false;
}
else{
helper=helper(Tags,n-1);
if(Tags[n-1].equalsIgnoreCase(tag)&&tag!=null)
result=true;}
另一个问题
如何定义writer 啊?
import java.io.*;
import java.util.*;
public class CollectionWriter{
private CollectionLoader collectionLoader;
public CollectionWriter(){
CollectionLoader=CollectionLoader();
}
public CollectionLoader getCorrespondLoader(){
return CollectionLoader;
}
public void save(PictureCollection collection,java.io.File path) throws java.io.IOException{
}
[em10]