Advertisement
Egor_Vakar

(Java) lab 4.1 Teams

Feb 22nd, 2022
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. public class Teams {
  2.     private String teamName;
  3.     private int teamPoints;
  4.     private String teamCountry;
  5.     private String coachName;
  6.  
  7.     Teams(){
  8.         this.teamName = "Team's name";
  9.         this.teamPoints = 0;
  10.         this.teamCountry = "Country";
  11.         this.coachName = "Coach's name";
  12.  
  13.  
  14.     }
  15.  
  16.  
  17.  
  18.     public String getTeamName() {
  19.         return teamName;
  20.     }
  21.  
  22.     public void setTeamName(String teamName) {
  23.         this.teamName = teamName;
  24.     }
  25.  
  26.     public int getTeamPoints() {
  27.         return teamPoints;
  28.     }
  29.  
  30.     public void setTeamPoints (int teamPoints) {
  31.         this.teamPoints = teamPoints;
  32.     }
  33.  
  34.     public String getTeamCountry() {
  35.         return teamCountry;
  36.     }
  37.  
  38.     public void setTeamCountry(String teamCountry) {
  39.         this.teamCountry = teamCountry;
  40.     }
  41.  
  42.     public String getCoachName() {
  43.         return coachName;
  44.     }
  45.  
  46.     public void setCoachName(String coachName) {
  47.         this.coachName = coachName;
  48.     }
  49.  
  50.     Teams(String name, int teamPoints, String teamCountry, String coachName){
  51.         this.teamName = name;
  52.         this.teamPoints = teamPoints;
  53.         this.teamCountry = teamCountry;
  54.         this.coachName = coachName;
  55.     }
  56.  
  57.     boolean isAlreadyExists(Teams newTeam){
  58.         boolean isSame;
  59.         isSame = this.getTeamName().equalsIgnoreCase(newTeam.getTeamName());
  60.         if (isSame){
  61.             isSame = this.getTeamPoints() == newTeam.getTeamPoints();
  62.         }
  63.         if (isSame){
  64.             isSame = this.getTeamCountry().equalsIgnoreCase(newTeam.getTeamCountry());
  65.         }
  66.         if (isSame){
  67.             isSame = this.getCoachName().equalsIgnoreCase(newTeam.getCoachName());
  68.         }
  69.         return isSame;
  70.     }
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement