0

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.

Edited by hatebin: n/a

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by hatebin
0

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.

-1

problem solved, just used another interface

Votes + Comments
Your lack of clarity regarding both the problem and the resultant solution is not beneficial to this community.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.