Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Instructions
- * Solve the problem with Java Code
- * Submit only the .java or .text file
- * Read the questions and write java code accordingly
- Read the following question and write shortcode for the questions:
- Read the following user-story and wite java code. Write Cricketer and Main class in
- different package and import Cricketer class in the Main class.
- Suppose, you have been given a task to develop a program that will
- manage the activity of a cricketer. A Cricketer has some property
- like name, age, country, number of runs, number of wickets, and numbers of matches.
- You have to write three methods named increaseRun, increaseWicket and increaseMatch
- those methods will increase run, wicket and match of cricketer. Each method will take
- a single parameter for run, wicket, and match respectively. Write another method named
- printInfo that will print all the information of that cricketer. Write another class
- named Controller. In the Controller class create an object of cricketer class and
- initialize the object. Take input from user for run, wicket and match and call all
- three methods. Finally call the printInfo method to print the details information.
- package com.company.controler;
- import com.company.cricketer.Cricketer;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- Cricketer c = new Cricketer();
- c.getInput();
- System.out.println("Today's Run: ");
- int increaseRun = input.nextInt();
- c.increaseRun(increaseRun);
- System.out.println("Today's Wicket: ");
- int increaseWicket = input.nextInt();
- c.increaseWicket(increaseWicket);
- System.out.println("increase match number: ");
- int increaseMatch = input.nextInt();
- c.increaseMatch(increaseMatch);
- c.printInfo();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement