package com.company;
public class Task {
public static void main (String [] args) {
Employer google = new Employer("Google", 500);
google.displayInfo();
Employee vasya = new Employee("Vasya", 400);
vasya.displayInfo();
evaluate (); {
if (google.salaryProposed >= vasya.salaryDesired) {
System.out.println("\nWe can hire Vasya! :)");
} else {
System.out.println("\nWe can't :(");
}
}
}
private static void evaluate() {
}
}
class Employer {
String name;
int salaryProposed;
Employer (String name, int salaryProposed) {
this.name = name;
this.salaryProposed = salaryProposed;
}
void displayInfo () {
System.out.printf ("Employer name: %s \t Employer salary proposed: %d \n", name, salaryProposed);
}
}
class Employee {
String name;
int salaryDesired;
Employee (String n, int sD) {
name = n;
salaryDesired = sD;
}
void displayInfo () {
System.out.printf ("Employee name: %s \t Employee salary desired: %d \n", name, salaryDesired);
}
}
displayInfo()
можно заменить на метод toString()
так как по факту он именно это и делает. evaluate (); {
if (google.salaryProposed >= vasya.salaryDesired) {
System.out.println("\nWe can hire Vasya! :)");
} else {
System.out.println("\nWe can't :(");
}
}
private static void evaluate() {
}
public class Main {
public static void main(String[] args) {
Employer google = new Employer("Google", 500);
System.out.println(google);
Employee vasya = new Employee("Vasya", 400);
System.out.println(vasya);
System.out.println("Result: " + SalaryService.evaluate(google.salaryProposed, vasya.salaryDesired));
}
}
class Employer {
String name;
int salaryProposed;
Employer (String name, int salaryProposed) {
this.name = name;
this.salaryProposed = salaryProposed;
}
@Override
public String toString() {
return "Employer{" +
"name='" + name + '\'' +
", salaryProposed=" + salaryProposed +
'}';
}
}
class Employee {
String name;
int salaryDesired;
Employee (String n, int sD) {
name = n;
salaryDesired = sD;
}
@Override
public String toString() {
return "Employee{" +
"name='" + name + '\'' +
", salaryDesired=" + salaryDesired +
'}';
}
}
class SalaryService {
public static String evaluate(int salaryProposed, int salaryDesired) {
if (salaryProposed >= salaryDesired) {
return "We can hire Vasya! :)";
} else {
return "We can't :(";
}
}
}
public class Task {
public static void main (String [] args) {
Employer company = new Employer("Godel", 500);
company.setCompanyName("Microsoft");
company.setCompanyName("EPAM");
company.setSalaryProposed(600);
company.setCompanyName("CoolCompany");
company.setSalaryProposed(1000);
Employee person = new Employee("Vasya", 400);
person.setPersonName("Petya");
person.setSalaryDesired(300);
person.setPersonName("Ivan");
person.setSalaryDesired(800);
SalaryService1.evaluate(company.getSalaryProposed(), person.getSalaryDesired(), company.getCompanyName(), person.getPersonName());
}
}
class Employer {
private String name;
private int salaryProposed;
public Employer (String companyName, int salaryProposed) {
this.name = companyName;
this.salaryProposed = salaryProposed;
}
public String getCompanyName () {
return this.name;
}
public void setCompanyName (String companyName) {
this.name = companyName;
}
public int getSalaryProposed () {return this.salaryProposed;}
public void setSalaryProposed (int salaryProposed) {this.salaryProposed = salaryProposed;}
}
class Employee {
private String name;
private int salaryDesired;
public Employee (String personName, int salaryDesired) {
this.name = personName;
this.salaryDesired = salaryDesired;
}
public String getPersonName () {
return this.name;
}
public void setPersonName (String personName) {
this.name = personName;
}
public int getSalaryDesired () {return this.salaryDesired;}
public void setSalaryDesired (int salaryDesired) {this.salaryDesired = salaryDesired;}
}
class SalaryService1 {
public static void evaluate (int salaryProposed, int salaryDesired, String companyName, String personName) {
System.out.println("Company name: " + companyName + "\tSalary proposed: " + salaryProposed + "\nPerson name: " + personName + "\tSalary desired: " + salaryDesired);
if (salaryProposed >= salaryDesired) {
System.out.println("\nWe can hire " + personName + "! :)");
} else {
System.out.println("\nWe can't :(");
}
}
}