Advertisement
the_alator

Untitled

May 28th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. //package ua.nure.rozdaybeda.Practice6.part3;
  2. ////
  3. //////import static org.junit.jupiter.api.Assertions.*;
  4. ////////
  5. //////////import java.util.Arrays;
  6. ////////////
  7. //////////////import org.junit.jupiter.api.Test;
  8. ////////////////
  9. //////////////////public class ParkingTest {
  10. //////////////////// @Test
  11. ////////////////////// public void ParkingConstructorTest(){
  12. //////////////////////// new Parking(1);
  13. ////////////////////////// new Parking(0);
  14. //////////////////////////// assertThrows(java.lang.NegativeArraySizeException.class, () -> new Parking(-1));
  15. ////////////////////////////// }
  16. //////////////////////////////// @Test
  17. ////////////////////////////////// public void totalParkingTest1(){
  18. //////////////////////////////////// Parking p = new Parking(1);
  19. ////////////////////////////////////// assertEquals("[0]", p.toString());
  20. //////////////////////////////////////// }
  21. //////////////////////////////////////////
  22. //////////////////////////////////////////// public synchronized int park(int place) {
  23. ////////////////////////////////////////////// if(place < 1 || place > parking.length)
  24. //////////////////////////////////////////////// throw new IndexOutOfBoundsException("There is no such place");
  25. //////////////////////////////////////////////////
  26. //////////////////////////////////////////////////// for(int parkPlace = place - 1; parkPlace < parking.length; parkPlace++)
  27. ////////////////////////////////////////////////////// if(parking[parkPlace] == 0) {
  28. //////////////////////////////////////////////////////// parking[parkPlace] = 1;
  29. ////////////////////////////////////////////////////////// return parkPlace + 1;
  30. //////////////////////////////////////////////////////////// }
  31. ////////////////////////////////////////////////////////////// return -1;
  32. //////////////////////////////////////////////////////////////// }
  33. //////////////////////////////////////////////////////////////////
  34. //////////////////////////////////////////////////////////////////// /**
  35. ////////////////////////////////////////////////////////////////////// * leaves the car from the parking
  36. //////////////////////////////////////////////////////////////////////// * @param place leave the car at this place
  37. ////////////////////////////////////////////////////////////////////////// * @return true if there was car or false if there wasnt car
  38. //////////////////////////////////////////////////////////////////////////// */
  39. ////////////////////////////////////////////////////////////////////////////// public boolean leave(int place) {
  40. //////////////////////////////////////////////////////////////////////////////// if(place < 1 || place > parking.length)
  41. ////////////////////////////////////////////////////////////////////////////////// throw new IndexOutOfBoundsException("There is no such place");
  42. //////////////////////////////////////////////////////////////////////////////////// if(parking[place] == 0)
  43. ////////////////////////////////////////////////////////////////////////////////////// return false;
  44. //////////////////////////////////////////////////////////////////////////////////////// parking[place] = 0;
  45. ////////////////////////////////////////////////////////////////////////////////////////// return true;
  46. //////////////////////////////////////////////////////////////////////////////////////////// }
  47. //////////////////////////////////////////////////////////////////////////////////////////////
  48. //////////////////////////////////////////////////////////////////////////////////////////////// @Override
  49. ////////////////////////////////////////////////////////////////////////////////////////////////// public String toString() {
  50. //////////////////////////////////////////////////////////////////////////////////////////////////// return Arrays.toString(parking);
  51. ////////////////////////////////////////////////////////////////////////////////////////////////////// }
  52. ////////////////////////////////////////////////////////////////////////////////////////////////////////}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement