السلام عليكم اخواني
انا بحاول اضيف هالمثود للاخير حسب ماهو مطلوب مني في الكوندشن سي بس ما عرفت يف اطلق طريقة true or fale والتعديل باخر الموضوع وانا محدد لعيه بلون احمر وهذا هو المطلوب
Condition is an interface that contains a single method that returns true or false.
// The Boats returned are those for which the method returns true when it is applied to them.
// Include thorough testing code in the main method.
وهذا الكود كامل
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mytask6;
import fahad_task16.Boat;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.concurrent.locks.Condition;
/**
*
* @author M
*/
public class BoatRegister {
ArrayList<Boat> regArray= new ArrayList<Boat>();
public void addBoat(Boat boat){
regArray.add(boat);
}
public Boat getBoat(int seqNo){
Boat ex = null;
for(Boat temp : regArray){
if(temp.getSeqNUMBER()==seqNo){
ex=temp;
}
}
return ex;
}
@Override
public String toString(){
String temp="";
for(Boat a : regArray)
temp =temp+"\n"+ a;
return temp;
}
public Boat deleteBoat(int seqNo){
Boat ex = null;
for(Boat temp : regArray){
if(temp.getSeqNUMBER()==seqNo){
int x = regArray.indexOf(temp);
ex=temp;
regArray.remove(x);
return ex;
}
}
return ex;
}
public ArrayList<Boat> getBoatsWhoseNameContains(String charSequence){
ArrayList<Boat> col=new ArrayList<Boat>();
for(Boat a : regArray){
if(a.getName().equals(charSequence)){
col.add(a);
}
}
return col;
}
public void GroupByClass(){
if(!regArray.isEmpty()){
Collections.sort(regArray, new Comparator(){
public int compare(Object o1, Object o2) {
Boat b1 = (Boat) o1;
Boat b2 = (Boat) o2;
return b1.getbClass().compareToIgnoreCase(b2.getbClass());
}
});
}
}
public ArrayList<Boat> getByCondition(Condition c){
ArrayList<Boat> a = new ArrayList<Boat>();
return a ;
}
interface condition
{ boolean satify)boat);
}
}
