Menu
Question Index
...

Write a program to get the fall of wickets in a match given the ball by ball activity.

Input (List) Output (List)
[2:false, 1:false, 0:false, 0:false, 1:false, 4:false, 0:false, 0:false, 1:false, 3:false, 4:false, 1:false, 0:true, 1:false, 0:true, 6:false, 4:false, 6:false] [1-17, 2-18]
[0:false, 0:false, 4:false, 4:false, 1:false, 4:false, 0:true, 0:false, 0:true, 6:false, 4:false, 6:false, 0:true, 1:false, 0:true, 6:false, 4:false, 6:false] [1-13, 2-13, 3-29, 4-30]
[0:true, 6:false, 4:false, 0:true, 2:false, 0:true, 0:true, 6:false, 4:false, 0:true, 2:false, 0:true] [1-0, 2-10, 3-12, 4-12, 5-22, 6-24]


import java.util.*;
class GetFallOfWickets
{
    public static void main(String s[])
    {
        List<BallActivity> ballActivities = new ArrayList<BallActivity>();
        ballActivities.add(new BallActivity(0, false));
        ballActivities.add(new BallActivity(0, false));
        ballActivities.add(new BallActivity(0, false));
        ballActivities.add(new BallActivity(0, true));
        ballActivities.add(new BallActivity(2, false));
        ballActivities.add(new BallActivity(1, false));
        ballActivities.add(new BallActivity(0, true));
        ballActivities.add(new BallActivity(3, false));
        ballActivities.add(new BallActivity(4, false));
        ballActivities.add(new BallActivity(2, false));
        ballActivities.add(new BallActivity(4, false));
        ballActivities.add(new BallActivity(0, true));
        List<String> fallOfWickets = getFallOfWickets(ballActivities);
        System.out.println("Fall of wickets : " + fallOfWickets);

    }


    private static List<String> getFallOfWickets(List<BallActivity> ballActivities) {
    return wickets;
    }

}
class BallActivity {

int runs;
boolean wicket;

public BallActivity(int runs, boolean wicket) {
this.runs = runs;
this.wicket = wicket;
}

@Override
public String toString() {
return runs + ":" + wicket;
}
}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App