Untitled

 avatar
unknown
plain_text
4 years ago
2.0 kB
6
Indexable
package com.company;

import java.util.*;

class FootBallTeam {
    private String code_name;
    private String name;
    private int ticket_price;

    public FootBallTeam(String code_name, String name, int ticket_price) {
        this.code_name = code_name;
        this.name = name;
        this.ticket_price = ticket_price;
    }


    public String getName() {
        return name;
    }

    public int getTicket_price() {
        return ticket_price;
    }
}

class Match {
    private FootBallTeam team;
    private String match_id;
    private int number_of_fans;

    public Match(FootBallTeam team, String match_id, int number_of_fans) {
        this.team = team;
        this.match_id = match_id;
        this.number_of_fans = number_of_fans;
    }

    private long income() {
        return (long)team.getTicket_price() * (long)number_of_fans;
    }

    @Override
    public String toString() {
        return match_id + " " + team.getName() + " " + income();
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String, FootBallTeam> teams = new HashMap<>();
        ArrayList<Match> matchArrays = new ArrayList<>();
        int No_team = sc.nextInt();
        for (int i = 0; i < No_team; i++) {
            sc.nextLine();
            String code_name = sc.nextLine();
            String name = sc.nextLine();
            int ticket_price = sc.nextInt();
            teams.put(code_name, new FootBallTeam(code_name, name, ticket_price));
        }
        int No_match = sc.nextInt();
        sc.nextLine();
        for (int i = 0; i < No_match; i++) {
            String match_id = sc.next();
            int fans = sc.nextInt();
            matchArrays.add(new Match(teams.get(match_id.substring(1, 3)), match_id, fans));
        }
        for (Match m : matchArrays) {
            System.out.println(m);
        }
    }
}
Editor is loading...