Aakhri Jung!
5 posters
Page 3 of 3
Page 3 of 3 • 1, 2, 3
Re: Aakhri Jung!
a) Which design pattern is used in this program? Select from the dropdown list below.
public class ClassA{
protected ClassB objectA;
protected String propertyA;
public ClassA(ClassB obj1,String obj2){
this.objectA=obj1;
this.propertyA=obj2;
}
public void MethodA(String message){
objectB.methodA(message);
}
public void MethodB(String message){
system.out.println(this.propertyA+": "+message);
}
}
public class ClassB{
private list listClassA;
public ClassB(){
listClassA=new list();
}
public void AddClassA(ClassA classA){
this.listClassA.add(classA);
}
public void MethodA(String message, ClassA classA){
for(Class obj:listClassA){ //iterate over each element of the collection
if(obj!=classA)
obj.MethodB(message);
}
}
}
??
public class ClassA{
protected ClassB objectA;
protected String propertyA;
public ClassA(ClassB obj1,String obj2){
this.objectA=obj1;
this.propertyA=obj2;
}
public void MethodA(String message){
objectB.methodA(message);
}
public void MethodB(String message){
system.out.println(this.propertyA+": "+message);
}
}
public class ClassB{
private list listClassA;
public ClassB(){
listClassA=new list();
}
public void AddClassA(ClassA classA){
this.listClassA.add(classA);
}
public void MethodA(String message, ClassA classA){
for(Class obj:listClassA){ //iterate over each element of the collection
if(obj!=classA)
obj.MethodB(message);
}
}
}
??
gorydog- Posts : 10
Join date : 2016-04-29
Re: Aakhri Jung!
Allow users to scan over and access the elements of a collection without knowing the underlying representation of the collection.
Iterator
Iterator
ledzep93- Posts : 9
Join date : 2016-04-29
Page 3 of 3 • 1, 2, 3
Page 3 of 3
Permissions in this forum:
You cannot reply to topics in this forum
|
|