SHARE
TWEET

Jaba 9

FlyChsCake Nov 15th, 2019 (edited) 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3. interface MainInterface {
  4.     public void input();
  5.     public void output();
  6.     public void method();
  7. }
  8.  
  9. class Dyscyplina implements MainInterface {
  10.     private String name;
  11.     private int lectHours;
  12.     private int labHours;
  13.     private int selfHours;
  14.    
  15.     public void input() {
  16.         Scanner in = new Scanner(System.in);
  17.         System.out.println("Input name: ");
  18.         name = in.nextLine();
  19.         System.out.println("Input lect hours: ");
  20.         lectHours = in.nextInt();
  21.         System.out.println("Input lab hours: ");
  22.         labHours = in.nextInt();
  23.         System.out.println("Input self hours: ");
  24.         selfHours = in.nextInt();
  25.     }
  26.    
  27.     public void output() {
  28.         System.out.printf("Name: %s\nLect hours: %s\nLab hours: %s\n Self hours: %s\n", name, lectHours, labHours,selfHours);
  29.     }
  30.    
  31.     public void method() {
  32.         System.out.printf("Total hours: %s\n", Integer.toString(lectHours + labHours + selfHours));
  33.     }
  34.    
  35. }
  36.  
  37. class Salary implements MainInterface {
  38.     private String fio;
  39.     private int hours;
  40.     private int payment;
  41.    
  42.     public void input() {
  43.         Scanner in = new Scanner(System.in);
  44.         System.out.println("Input fio: ");
  45.         fio = in.nextLine();
  46.         System.out.println("Input hours of work: ");
  47.         hours = in.nextInt();
  48.         System.out.println("Input payment for hour: ");
  49.         payment = in.nextInt();
  50.     }
  51.    
  52.     public void output() {
  53.         System.out.printf("Name: %s\nHours of work: %s\nPayment: %s\n", fio, hours, payment);
  54.     }
  55.    
  56.     public void method() {
  57.         System.out.printf("Total payout: %s\n", Integer.toString(hours * payment));
  58.     }
  59.    
  60. }
  61.  
  62. class Providers implements MainInterface {
  63.     private String name;
  64.     private int speed;
  65.     private int price;
  66.    
  67.     public void input() {
  68.         Scanner in = new Scanner(System.in);
  69.         System.out.println("Input name: ");
  70.         name = in.nextLine();
  71.         System.out.println("Input speed: ");
  72.         speed = in.nextInt();
  73.         System.out.println("Input price: ");
  74.         price = in.nextInt();
  75.     }
  76.    
  77.     public void output() {
  78.         System.out.printf("Name: %s\nSpeed: %s\nPrice: %s\n", name, speed, price);
  79.     }
  80.    
  81.     public void method() {
  82.         System.out.printf("Price/Speed: %s\n", price / speed);
  83.     }
  84.    
  85. }
  86.  
  87.  
  88. public class MyClass {
  89.     public static void main(String args[]) {
  90.       MainInterface mi[] = new MainInterface[3];
  91.       mi[0] = new Dyscyplina();
  92.       mi[1] = new Salary();
  93.       mi[2] = new Providers();
  94.       for(MainInterface x: mi) {
  95.           x.input();
  96.           x.output();
  97.           x.method();
  98.       }
  99.     }
  100. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top