Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Random;
- public class Stream {
- // Variables
- Streamer streamer;
- String gameBeenPlaying;
- String title;
- ArrayList <String> categories;
- // Random-made variables
- int viewers;
- int secondsStreaming;
- // Constructors
- Stream(){
- streamer = new Streamer();
- gameBeenPlaying = "";
- title = "";
- categories = new ArrayList <String> ();
- viewers = 0;
- secondsStreaming = 0;
- }
- Stream(Streamer streamer, String gameBeenPlaying, String title, ArrayList <String> categories){
- this.streamer = streamer;
- this.gameBeenPlaying = gameBeenPlaying;
- this.title = title;
- this.categories = categories;
- // About "viewers"
- Random randomObject = new Random();
- int indexOfViewers = randomObject.nextInt(10);
- // The above variable has a value from 0 to 9 (inclusive) ---> 10 possible values
- // I want this one to be true
- // Probability(0 <= viewers <= 99) = 3 / 10
- // Probability(100 <= viewers <= 999) = 5 / 10
- // Probability(1000 <= viewers <= 9999) = 2 / 10
- if(indexOfViewers >= 0 && viewers <= 2) {
- this.viewers = randomObject.nextInt(100);
- }
- else if(indexOfViewers >= 3 && indexOfViewers <= 7) {
- this.viewers = randomObject.nextInt(900) + 100;
- }
- else {
- this.viewers = randomObject.nextInt(9000) + 1000;
- }
- // About "secondsStreaming"
- // I want this:
- // Probability(0s <= timeStreaming < 3600s = 1h) = 3 / 10
- // Probability(3600s <= timeStreaming < 7200s = 2h) = 3 / 10
- // Probability(7200s <= timeStreaming < 10800s = 3h) = 3 / 10
- // Probability(10800s <= timeStreaming < 14400s = 4h) = 1 / 10
- int indexOfSecondsStreaming = randomObject.nextInt(10);
- if(indexOfSecondsStreaming >= 0 && indexOfSecondsStreaming <= 2){
- this.secondsStreaming = randomObject.nextInt(3600);
- }
- else if(indexOfSecondsStreaming >= 3 && indexOfSecondsStreaming <= 5){
- this.secondsStreaming = randomObject.nextInt(3600) + 3600;
- }
- else if(indexOfSecondsStreaming >= 6 && indexOfSecondsStreaming <= 8){
- this.secondsStreaming = randomObject.nextInt(3600) + 7200;
- }
- else{
- this.secondsStreaming = randomObject.nextInt(3600) + 10800;
- }
- } // END OF 2ND CONSTRUCTOR
- // Methods
- void convertSeconds(int seconds) {
- }
- void showStatus() {
- System.out.println("Streamer: " + streamer.name);
- System.out.println("Game Been Playing Now: " + gameBeenPlaying);
- System.out.println("Title: " + title);
- System.out.println("Categories: ");
- if(categories.size() != 0) {
- for(int i=0; i<categories.size(); i++) {
- System.out.println(categories.get(i));
- }
- }
- else {
- System.out.println("Streamer " + streamer.name + " has not added categories yet!");
- }
- System.out.println("Viewers: " + viewers);
- System.out.println("Seconds streaming: " + secondsStreaming);
- } // END OF FUNCTION SHOWSTATUS
- } // END OF CLASS STREAM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement