Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. import java.util.*;
  2.  
  3.  public class DotCom{
  4.    
  5.     private ArrayList<String> locationCells;
  6.     private String name;
  7.    
  8.     public void setLocationCells(ArrayList<String> loc){
  9.         locationCells=loc;
  10.     }
  11.    
  12.     public void setName(String n){
  13.         name=n;
  14.     }
  15.    
  16.     public String checkYourself(String userInput){
  17.         String result="Мимо";
  18.         int index = locationCells.indexOf(userInput);
  19.         if (index>=0){
  20.             locationCells.remove(index);
  21.             if (locationCells.isEmpy()){
  22.                 result="Потопил";
  23.                 System.out.println("Вы потопили: " + name);
  24.             }
  25.             else result = "Попал";
  26.         }
  27.         return result;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement