Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- interface MainInterface {
- public void input();
- public void output();
- public void method();
- }
- class Dyscyplina implements MainInterface {
- private String name;
- private int lectHours;
- private int labHours;
- private int selfHours;
- public void input() {
- Scanner in = new Scanner(System.in);
- System.out.println("Input name: ");
- name = in.nextLine();
- System.out.println("Input lect hours: ");
- lectHours = in.nextInt();
- System.out.println("Input lab hours: ");
- labHours = in.nextInt();
- System.out.println("Input self hours: ");
- selfHours = in.nextInt();
- }
- public void output() {
- System.out.printf("Name: %s\nLect hours: %s\nLab hours: %s\n Self hours: %s\n", name, lectHours, labHours,selfHours);
- }
- public void method() {
- System.out.printf("Total hours: %s\n", Integer.toString(lectHours + labHours + selfHours));
- }
- }
- class Salary implements MainInterface {
- private String fio;
- private int hours;
- private int payment;
- public void input() {
- Scanner in = new Scanner(System.in);
- System.out.println("Input fio: ");
- fio = in.nextLine();
- System.out.println("Input hours of work: ");
- hours = in.nextInt();
- System.out.println("Input payment for hour: ");
- payment = in.nextInt();
- }
- public void output() {
- System.out.printf("Name: %s\nHours of work: %s\nPayment: %s\n", fio, hours, payment);
- }
- public void method() {
- System.out.printf("Total payout: %s\n", Integer.toString(hours * payment));
- }
- }
- class Providers implements MainInterface {
- private String name;
- private int speed;
- private int price;
- public void input() {
- Scanner in = new Scanner(System.in);
- System.out.println("Input name: ");
- name = in.nextLine();
- System.out.println("Input speed: ");
- speed = in.nextInt();
- System.out.println("Input price: ");
- price = in.nextInt();
- }
- public void output() {
- System.out.printf("Name: %s\nSpeed: %s\nPrice: %s\n", name, speed, price);
- }
- public void method() {
- System.out.printf("Price/Speed: %s\n", price / speed);
- }
- }
- public class MyClass {
- public static void main(String args[]) {
- MainInterface mi[] = new MainInterface[3];
- mi[0] = new Dyscyplina();
- mi[1] = new Salary();
- mi[2] = new Providers();
- for(MainInterface x: mi) {
- x.input();
- x.output();
- x.method();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement