Hello.

My code describes Color classes:

abstract class Color{
    
    private final int H=45;
    private int V;
    private int S;
    
   
    Color(int V,int S){
        this.V=V;
        this.S=S;
    }
    public int getV(){
        return V;
    }
    
    public int getS(){
        return S;
    }
    
    public void setV(int V){
        this.V=V;
    }
    
    abstract void print();
}

class Black extends Color{
    Black(){
        super(0,0);
    }
    @Override
  public void print(){ System.out.println("Black"); }  
}


abstract class Dekorator extends Color{
Color color;
    Dekorator(Color color){
        super(color.getV(),color.getS());
    }
    @Override
    public void print(){
        color.print();
}

class MoreVvalue extends Dekorator{
    private final int Vplus=15;
    
     MoreVvalue(Color color){
        super(color);
    }

        @Override
        public void setV(int Vplus) {
            super.setV(Vplus);
        }
     
}

Using a decorator pattern i want to create brighter version(setting the V by adding to its crrent value 15) of black color. Please help.

Recommended Answers

So, what is the problem you're facing? I can't help you till you define your problem in lucid terms. In this forum, we won't solve the entire thing for you. Tell me where you're stuck exactly.

Jump to Post

All 2 Replies

So, what is the problem you're facing? I can't help you till you define your problem in lucid terms. In this forum, we won't solve the entire thing for you. Tell me where you're stuck exactly.

problem solved, just used another interface

commented: Your lack of clarity regarding both the problem and the resultant solution is not beneficial to this community. -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.