Answered step by step
Verified Expert Solution
Question
1 Approved Answer
how can i make this class generateAvg return 0 before getting the average using observable? make it initially have no average 3+ import java.util.Observable;. 6
how can i make this class generateAvg return 0 before getting the average using observable?
make it initially have no average
3+ import java.util.Observable;. 6 public class generateAvg extends Observable { private int seed; double average = 0; private Random r = new Random(); 10 126 13 14 15 public generateAvg(int seed) { this. seed = seed; r.setSeed(this.seed); } 16 176 18 public double getAvg() { average = r.nextDouble()*10.0; return average; } 19 20 /** * Updates radiation, changes the state to true, and notifies all observers of * the change. 25 266 27 public void readRadiation() { setChanged(); notifyObservers(getAvg()); } 28 29 30 } }Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started