Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Date;
- import java.util.ArrayDeque;
- import java.text.SimpleDateFormat;
- import java.text.DateFormat;
- import java.time.LocalDate;
- import java.text.ParseException;
- interface SomeInterface {
- public void input();
- public void output();
- public double method();
- }
- class Film implements SomeInterface{
- private String title, director;
- private int releaseYear;
- private double cost, profit;
- public Film(String title, String director, int releaseYear, double cost, double profit) {
- this.title = title;
- this.director = director;
- this.releaseYear = releaseYear;
- this.cost = cost;
- this.profit = profit;
- input();
- }
- public void input() {
- if (releaseYear < 0) {
- throw new IllegalArgumentException("The year of the creation can not be a negative number");
- }
- if (cost < 0) {
- throw new IllegalArgumentException("The cost can not be a negative number");
- }
- if (profit < 0) {
- throw new IllegalArgumentException("The profit can not be a negative number");
- }
- }
- @Override
- public String toString() {
- return String.format("\nFilm object\nTitle: %s\nDirector: %s\nYear of the release: %d\nCost: %.2f\nProfit: %.2f", title, director, releaseYear, cost, profit);
- }
- @Override
- public int hashCode() {
- return releaseYear * releaseYear;
- }
- public void output() {
- System.out.print( toString() );
- }
- public double method() {
- return profit - cost;
- }
- }
- class Masterpiece implements SomeInterface{
- private String vudMustectva, title, author;
- private int creationYear;
- public Masterpiece(String vudMustectva, String title, String author, int creationYear) {
- this.vudMustectva = vudMustectva;
- this.title = title;
- this.author = author;
- this.creationYear = creationYear;
- input();
- }
- public void input() {
- if (creationYear < 0) {
- throw new IllegalArgumentException("The year of the creation can not be a negative number");
- }
- }
- @Override
- public String toString() {
- return String.format("\nMasterpiece object\nVud mustectva: %s\nTitle: %s\nAuthor: %s\nYear of the creation: %d", vudMustectva, title, author, creationYear);
- }
- @Override
- public int hashCode() {
- return creationYear * creationYear;
- }
- public void output() {
- System.out.print( toString() );
- }
- public double method() {
- LocalDate date_now = LocalDate.now();
- return date_now.getYear() - creationYear;
- }
- }
- class Brigade implements SomeInterface{
- private Date date;
- private int employeesAmount;
- private double plan, factVurobitok;
- public Brigade(String date, int employeesAmount, double plan, double factVurobitok ) throws Exception {
- this.date = new SimpleDateFormat("dd/MM/yyyy").parse(date);
- this.employeesAmount = employeesAmount;
- this.plan = plan;
- this.factVurobitok = factVurobitok;
- input();
- }
- public void input() {
- if (employeesAmount < 0) {
- throw new IllegalArgumentException("Amount of employees can not be a negative number");
- }
- if (plan < 0) {
- throw new IllegalArgumentException("Plan can not be a negative number");
- }
- if (factVurobitok < 0) {
- throw new IllegalArgumentException("Fact. vurobitok can not be a negative number");
- }
- }
- @Override
- public String toString() {
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- return String.format("\nBrigade object\nDate: %s\nEmployees amount: %s\nPlan: %s\nFact. vurobitok: %s", dateFormat.format(date), employeesAmount, plan, factVurobitok);
- }
- @Override
- public int hashCode() {
- return employeesAmount * employeesAmount;
- }
- public void output() {
- System.out.print( toString() );
- }
- public double method() {
- return 100 / plan * factVurobitok;
- }
- }
- public class lab10 {
- public static void main(String[] args) throws Exception {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement