package cz.vutbr.feec.burget.advanced;

import java.util.Random;

public class Receiver extends Member {
	private double time = 0;
	private double value = 0;
	
	public Receiver(double period) {
		this.time = period;
	}

	@Override
	public void afterFeedbackSent() {
		// nedelej nic
	}

	@Override
	public void beforeFeedbackSent() {
		// cekej 5 sec * nahodny interval:<0.5, 1.5>
		
		Random rnd = new Random();
		double rndTime = time * ( 0.5 + rnd.nextDouble());
		sleepProc(rndTime);

	}

	@Override
	public void onFeedbackSent(Member m) {
		m.onFeedbackReceived(this);
	}

	@Override
	public void onFeedbackReceived(Member m) {
		System.out.println("Obdrzena odezva od: "+m);
	}
	@Override
	public String toString() {
		return "RR:"+getMemberId();
	}

	public double getValue() {
		return value;
	}

	public void setValue(double value) {
		this.value = value;
	}
}
