Advertisement
Sabbir-bin

week 6 main

Jul 4th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. Instructions
  2. * Solve the problem with Java Code
  3. * Submit only the .java or .text file
  4. * Read the questions and write java code accordingly
  5.  
  6. Read the following question and write shortcode for the questions:
  7.  
  8. Read the following user-story and wite java code. Write Cricketer and Main class in
  9. different package and import Cricketer class in the Main class.
  10. Suppose, you have been given a task to develop a program that will
  11. manage the activity of a cricketer. A Cricketer has some property
  12. like name, age, country, number of runs, number of wickets, and numbers of matches.
  13. You have to write three methods named increaseRun, increaseWicket and  increaseMatch
  14. those methods will increase run, wicket and match of cricketer. Each method will take
  15. a single parameter for run, wicket, and match respectively.  Write another method named
  16.  printInfo that will print all the information of that cricketer. Write another class
  17.  named Controller. In the Controller class create  an object of cricketer class and
  18. initialize the object.  Take input from user for run, wicket and match and call all
  19. three methods. Finally call the printInfo method to print the details information.
  20.  
  21. package com.company.controler;
  22.  
  23. import com.company.cricketer.Cricketer;
  24.  
  25. import java.util.Scanner;
  26.  
  27. public class Main {
  28.     public static void main(String[] args) {
  29.         Scanner input = new Scanner(System.in);
  30.         Cricketer c = new Cricketer();
  31.  
  32.         c.getInput();
  33.  
  34.         System.out.println("Today's Run: ");
  35.         int increaseRun = input.nextInt();
  36.         c.increaseRun(increaseRun);
  37.  
  38.         System.out.println("Today's Wicket: ");
  39.         int increaseWicket = input.nextInt();
  40.         c.increaseWicket(increaseWicket);
  41.  
  42.         System.out.println("increase match number: ");
  43.         int increaseMatch = input.nextInt();
  44.         c.increaseMatch(increaseMatch);
  45.  
  46.         c.printInfo();
  47.  
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement