id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
6e9873ec-7bd0-4995-95a6-9ba4aea5c187 | public void setUser(User user) {
this.user = user;
} |
7db3df41-0516-4cbe-b959-07c73378ff03 | @Override
public void setSession(Map<String, Object> session) {
this.session = session;
} |
a7eaae2b-0e04-4b57-8c4c-4534555d9f3f | @Override
public Employee getModel() {
return employee;
} |
dd7bae7c-58c5-4267-b6db-7a8ca69d290e | public void validate() {
if (getEmployee().getFirstname().trim().length() == 0) {
addFieldError("firstname", "First name is required.");
}
} |
20e946c2-edfb-4104-9f4b-3c1064fca9c5 | @Action(value = "addAction", results = {
@Result(name = "success", type = "redirectAction", location = "listAction.action"),
@Result(name = "input", location = "/employee/add.jsp") })
public String addEmployee() throws Exception {
System.out.println("ADD EMPLOYEE");
System.out.println(employee);
employee... |
e30a2a68-77be-4c31-bce7-ee67c09df13b | @Action(value = "listAction", results = { @Result(name = "success", location = "/employee/list.jsp") })
@SkipValidation
public String listEmployees() throws Exception {
employees = employeeService.getAll();
return "success";
} |
0354a9a7-00b5-4fb1-af96-e553f322fa27 | public Employee getEmployee() {
return employee;
} |
77d7b6b7-8722-4e87-8587-25e7a4b98a29 | public void setEmployee(Employee employee) {
this.employee = employee;
} |
6f8ed999-36ff-433d-895e-24c6130402b2 | public List<Employee> getEmployees() {
return employees;
} |
b8e5ea59-6ccd-4262-be1c-3082a19c59d6 | public void setEmployees(List<Employee> employees) {
this.employees = employees;
} |
323cbaad-df35-4385-9b4a-04cd3e8a14e7 | public static void main(String[] args){
System.out.println("Hello World");
} |
f39e84e5-4484-4b75-b089-da8fd2bab75c | public static void main(String[] args){
System.out.println("Olá Mundo!!!");
} |
2399244e-66a5-4196-83b1-7ebb3d5e7a33 | public static void main(String[] args){
//System.out.println("Hello World");
System.out.println("Vc digitou " + 1/0);
} |
d83e81f1-c6a9-4455-8239-591f410649b7 | public static void main(String[] args){
System.out.println("Hello World");
} |
5959fe94-6472-4319-9ca0-866661350f76 | public static void main(String[] args){
int cont = 0;
System.out.println("Vc digitou " + cont);
} |
f6901c14-f1f4-47ae-a13d-67746e4117a9 | public static void main(String[] args){
System.out.println("Você digitou " + args[0]);
} |
32834d47-f533-4a43-a8b0-c8f01ed52da0 | public static void main(String[] args){
System.out.println("Olá Mundo " + args[0]);
} |
75c1adc1-c525-4876-94bb-38d9ff41e121 | public static void main(String args[])
{
@SuppressWarnings("unused")
MinesweeperMainFrame game = new MinesweeperMainFrame();
} |
5e988481-457d-4600-aaee-7d76f3dbde07 | public static boolean shouldBeABomb()
{
double rand = Math.random();
if (rand < DEFAULT_BOMB_GENERATION_RATIO)
return true;
else
return false;
} |
91933fda-7bb5-4d27-b643-eae0bde77e8a | public int getSquareType()
{
return GridSquare.BOMB;
} |
d2f5602d-ca0d-48ce-8cad-00a87dd0425b | public BombSquare(int yCoordinate, int xCoordinate)
{
super(xCoordinate, yCoordinate);
} |
482e3aad-5202-4f24-b807-f827d5c339b6 | public void leftClick()
{
if (!this.isFlagged())
{
this.setCovered(false);
parentFrame.gameOver();
setBackground(BLOW_UP);
}
} |
a74df1a8-cfd0-4370-a043-bcc485ce9272 | public void rightClick()
{
super.rightClick();
} |
68f054f2-a37b-4cd5-8357-2082defcf21b | public MinesweeperMainFrame()
{
super("Minesweeper");
setLayout(new BorderLayout());
setupMenu();
setupGrid();
setupFrame();
} |
9960487f-164b-42d1-a1e7-f459c512df9b | private void setupGrid()
{
theGrid = new MinesweeperGridFrame(DEFAULT_GRID_ROWS, DEFAULT_GRID_COLUMNS);
this.add(theGrid, BorderLayout.CENTER);
} |
6bcae282-aa0d-4719-8fa4-ad1f1f2691c3 | private void setupFrame()
{
this.setVisible(true);
this.pack();
this.setMinimumSize(new Dimension(400, 400));
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
} |
8d937562-2073-4d8a-867c-01b234f3cdbf | private void setupMenu()
{
theMenuBar = new JMenuBar();
fileMenu = new JMenu("File");
theMenuBar.add(fileMenu);
JMenuItem newGame = new JMenuItem("New Game");
newGame.addActionListener(this);
newGame.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_1, ActionEvent.ALT_MASK));
newGame.get... |
38b19d62-136a-4146-8b27-2084b977dda5 | public void actionPerformed(ActionEvent e)
{
this.remove(theGrid);
theGrid = new MinesweeperGridFrame(DEFAULT_GRID_ROWS, DEFAULT_GRID_COLUMNS);
this.add(theGrid);
this.pack();
} |
62a5f3ad-39b8-4cbe-bdba-623d829c325e | public MinesweeperGridFrame(int gridRows, int gridColumns)
{
super();
numActiveBombs = 0;
badFlags = 0;
squaresLeft = gridRows * gridColumns;
max_xCoordinate = gridColumns;
max_yCoordinate = gridRows;
gridSquare2DArray = new GridSquare[gridRows][gridColumns];
setLayout(new Grid... |
4283bfb4-c425-4a14-9948-b97c657bd089 | public void setGrid(GridSquare[][] grid, int numBombs)
{
gridSquare2DArray = grid;
max_yCoordinate = grid.length;
max_xCoordinate = grid[0].length;
squaresLeft = max_xCoordinate * max_yCoordinate;
numActiveBombs = numBombs;
totalBombs = numBombs;
} |
051a4492-8564-410b-b640-379537742a16 | protected MinesweeperGridFrame()
{
super();
} |
cbd6227d-51bf-449c-bd55-d91b7fa2d730 | private void buildGrid(int gridRows, int gridColumns)
{
GridSquare temp;
for (int y = 0; y < gridRows; ++y)
{
for (int x = 0; x < gridColumns; ++x)
{
temp = GridSquare.newGridSquare(y, x);
temp.setParentFrame(this);
add(temp);
if (temp.getSquareType() == GridSquare.BOMB)
... |
ef011bcc-c047-4f48-9614-bed021553a2d | public void decrementFlaggedBombs()
{
numActiveBombs--;
} |
bff91b87-fe8c-4ac3-995f-2587410fb838 | public void incrementFlaggedBombs()
{
numActiveBombs++;
} |
53e3dcf0-ced1-4d9e-9bd8-ab03d8356142 | public void decrementBadFlags()
{
badFlags--;
} |
e63e9db5-222f-49a4-97e3-24efd9152bf3 | public void incrementBadFlags()
{
badFlags++;
} |
491e3b4b-7e41-49ac-9824-5dd26b0981d9 | public int numActiveBombs()
{
return numActiveBombs;
} |
41d96fdd-7291-4515-a0c1-88d502af2739 | public int numBadFlags()
{
return badFlags;
} |
09b18174-d186-4ade-af4a-f632ba6b4f9f | public boolean isGameWon()
{
return (badFlags == 0) && ((numActiveBombs == 0) || (totalBombs == squaresLeft));
} |
f2013256-0f6f-493e-ad67-7a78c3382750 | public void gameOver()
{
for (GridSquare[] rows : gridSquare2DArray)
{
for (GridSquare square : rows)
{
if (square.getSquareType() == GridSquare.BOMB && !square.isFlagged())
{
square.setBackground(BombSquare.BLOW_UP);
}
}
}
} |
6d392a44-4ab2-405f-91f7-fc5e9916ae55 | public void uncover(GridSquare origin)
{
ArrayList<GridSquare> toUncover = new ArrayList<GridSquare>();
toUncover.add(origin);
int bombsAround;
GridSquare square;
while (!toUncover.isEmpty())
{
square = toUncover.remove(0);
if (!square.... |
6b82706d-df88-4216-a451-9cf61f58313c | private int countNeighboringBombs(GridSquare square)
{
int xCoordinate = square.getXCoordinate();
int yCoordinate = square.getYCoordinate();
int numBombs = 0;
if (coordinatesAreInGrid(yCoordinate, xCoordinate - 1))
{
if (gridSquare2DArray[yCoordinate][xC... |
08a1858f-5fd3-4574-8c11-5d92bf1a9cf9 | private void addNeighbors(GridSquare square, ArrayList<GridSquare> toUncover)
{
int xCoordinate = square.getXCoordinate();
int yCoordinate = square.getYCoordinate();
if (coordinatesAreInGrid(yCoordinate, xCoordinate - 1) && gridSquare2DArray[yCoordinate][xCoordinate - 1].getSquareType() != ... |
32ef47fb-7ec3-4182-a89e-292d01ec2dac | private boolean coordinatesAreInGrid(int yCoordinate, int xCoordinate)
{
return (yCoordinate >= 0 && yCoordinate < max_yCoordinate && xCoordinate >= 0 && xCoordinate < max_xCoordinate);
} |
b96e92c0-60c4-4c95-9239-afe77399466e | public static GridSquare newGridSquare(int yCoordinate, int xCoordinate)
{
if (BombSquare.shouldBeABomb())
return new BombSquare(xCoordinate, yCoordinate);
else
return new GridSquare(xCoordinate, yCoordinate);
} |
278a3ddd-68f6-4765-8be0-ce1d0d8c00fe | public GridSquare(int xCoordinate, int yCoordinate)
{
super();
this.isCovered = true;
this.isFlagged = false;
this.inProcessing = false;
this.parentFrame = null;
this.numberOfBombsAround = new JLabel("");
this.add(numberOfBombsAround);
this.xCoordinate = xC... |
1d2a04c6-ad68-41f2-b535-8f2236e6f87e | public void setParentFrame(MinesweeperGridFrame parent)
{
this.parentFrame = parent;
} |
e48d0cb0-5e00-48a1-a358-684b71ed74dc | public int getXCoordinate()
{
return xCoordinate;
} |
0a97c651-cad8-4488-b7e8-46ba7224bde7 | public int getYCoordinate()
{
return yCoordinate;
} |
20a08f35-c89d-4bf0-a593-df28d180f8ad | public int getSquareType()
{
return EMPTY;
} |
7cb7068b-a7ca-4a29-96e7-d073c9c02ec5 | public void setCovered(boolean covered) {
this.isCovered = covered;
} |
9327afb1-5ecf-4698-836d-15d13e784f48 | public boolean isCovered()
{
return isCovered;
} |
a0d332c7-46a7-47cb-9784-2e784a6e3444 | public boolean isFlagged()
{
return isFlagged;
} |
3cd76546-5411-4670-9d8e-647a0bd2fdde | public boolean isInProcessing()
{
return inProcessing;
} |
ce0b3e82-2388-49ab-a00e-429647a49105 | public void startProcessing()
{
inProcessing = true;
} |
2e79b911-5c78-4e1f-bd54-5b4c14b4c306 | public void stopProcessing()
{
inProcessing = false;
} |
4654e124-b510-4aa4-98d8-636c3f19041c | public void leftClick()
{
if (!isFlagged)
uncover();
if (parentFrame.isGameWon())
System.out.println("YOU WIN!");
} |
21c6752f-f857-45f6-b162-4f86ed805293 | public void rightClick()
{
if (this.isCovered())
{
if (!isFlagged && this.getSquareType() == BOMB)
{
parentFrame.decrementFlaggedBombs();
}
else if (isFlagged && this.getSquareType() == BOMB)
{
parentFrame.incrementFlaggedBombs();
}
... |
0bb94e05-366d-41ba-af5e-0c908e446c3c | private void swapColor()
{
if (isCovered())
{
if (this.isFlagged)
this.setBackground(FLAGGED_COLOR);
else
this.setBackground(NON_ACTIVE_COLOR);
}
} |
cdab95df-ff44-4001-bccd-e733e21f3c62 | public void uncover()
{
parentFrame.uncover(this);
} |
dd1eecd5-cfea-4cd5-8643-92d861ef24d9 | public void unFlag()
{
this.isFlagged = false;
} |
e8e6bfe0-70ea-4571-92d1-42b0a56ee360 | public void setBombText(int numBombsAround)
{
numberOfBombsAround.setText("" + numBombsAround);
} |
8a13d8f2-0f21-482b-b284-1a8ae749cdb8 | @Override
public void mouseClicked(MouseEvent e)
{
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK)
leftClick();
else
rightClick();
} |
6b9fcd60-efc3-4092-beff-2427a0d98b82 | @Override
public void mouseEntered(MouseEvent arg0) {
// fTODO Auto-generated method stub
} |
e484f1ae-994c-4838-8020-85517f99eecb | @Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
} |
376ad389-5cc3-4e82-a24e-cdfc1127b51c | @Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
} |
95605f9b-0d7c-4f2d-8697-c45a5a459222 | @Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
} |
7f45bd1a-0ffc-408e-8e67-a2acb6383d12 | @Before
public void setUp()
{
MinesweeperGridFrame frame = createNiceMock(MinesweeperGridFrame.class);
square0 = new BombSquare(0,0);
square0.setParentFrame(frame);
} |
55d19a33-1c22-4d45-8cb2-4cab1b0d8d84 | @Test
public void bombSquareShouldReturnTypeOfBomb()
{
replayAll();
assertEquals(square0.getSquareType(), GridSquare.BOMB);
} |
53c686dd-8f1d-4828-ba0c-82b4b8302716 | @Test
public void bombSquareShouldBlowUpWhenLeftClickedAndNotFlagged()
{
replayAll();
square0.leftClick();
assertTrue(square0.getBackground().equals(BombSquare.BLOW_UP));
} |
25f20856-1fe3-4815-a1ac-89baaa7335fd | @Test
public void bombSquareShouldNotBlowUpWhenLeftClickedAndFlagged()
{
replayAll();
square0.rightClick();
square0.leftClick();
assertFalse(square0.getBackground().equals(BombSquare.BLOW_UP));
} |
a14e6a69-3705-41f1-8765-0a8b358558ce | @Before
public void setUp()
{
String[][] testGrid = {
{ "LE", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "LE", "LB", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
};
frame = new GridFrameTestDoubl... |
b8a23f61-264f-44d6-b653-3f7a5dab33e6 | @Test
public void decrementFlaggedBombsTest()
{
frame.decrementFlaggedBombs();
assertEquals(initialNumBombs - 1, frame.numActiveBombs());
} |
61165eeb-474f-43ab-8acb-165c9c1bf074 | @Test
public void incrementFlaggedBombsTest()
{
frame.incrementFlaggedBombs();
assertEquals(initialNumBombs + 1, frame.numActiveBombs());
} |
2326beb6-f340-40c5-bf04-d91db21d7602 | @Test
public void decrementBadFlagsTest()
{
frame.decrementBadFlags();
assertEquals(-1, frame.numBadFlags());
} |
84e41392-96d9-4f98-80fc-05d686d04dd1 | @Test
public void incrementBadFlagsTest()
{
frame.incrementBadFlags();
assertEquals(1, frame.numBadFlags());
} |
2e4ae21b-a072-46c1-b610-06cda5326951 | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeTopLeft()
{
frame.uncover(new GridSquare(-1, -1));
} |
3e98455e-da74-4f35-a536-284a2138af8b | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeTopRight()
{
frame.uncover(new GridSquare(-1, FRAME_WIDTH + 1));
} |
fb8b1279-be89-4cce-967b-adf95652d41b | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeBottomRight()
{
frame.uncover(new GridSquare(FRAME_HEIGHT + 1, FRAME_WIDTH + 1));
} |
5c117d03-9452-4c72-b64d-ad60df0a7619 | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeBottomLeft()
{
frame.uncover(new GridSquare(FRAME_HEIGHT + 1, -1));
} |
888cd7c0-665e-4e6b-ba93-152d89f2fccf | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeBottom()
{
frame.uncover(new GridSquare(FRAME_HEIGHT + 1, FRAME_WIDTH));
} |
6326a426-e4d6-4278-ac72-ccac02671440 | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeTop()
{
frame.uncover(new GridSquare(-1, FRAME_WIDTH));
} |
24e803d3-7332-483e-ac87-2fbcd03d2c22 | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeLeft()
{
frame.uncover(new GridSquare(FRAME_HEIGHT, -1));
} |
cf610970-20ab-4f20-9a77-8f3b46ca43a2 | @Test
public void uncoverDoesNotFailWhenCalledOutsideGridRangeRight()
{
frame.uncover(new GridSquare(FRAME_HEIGHT, FRAME_WIDTH + 1));
} |
e720d22c-8376-48ca-8d54-8574b3b37069 | @Test public void uncoveringEmptySquareNotNearBombShouldUncoverAdditionalSquares()
{
frame.click(0);
assertEquals(GridSquare.CLEARED, frame.theGrid[0][0].getBackground());
assertEquals(GridSquare.CLEARED, frame.theGrid[4][4].getBackground());
} |
0101cf39-3821-420b-8f66-e916b8ecd217 | @Test public void uncoveringEmptySquareNearBombShouldNotUncoverAdditionalSquares()
{
frame.click(1);
assertEquals(GridSquare.ALERT, frame.theGrid[2][1].getBackground());
assertEquals(GridSquare.NON_ACTIVE_COLOR, frame.theGrid[4][4].getBackground());
} |
63be97f3-3d8d-4c93-a34c-24bf0a02ee8d | @Test public void uncoveringABombShouldMakeItExplode()
{
frame.click(2);
assertEquals(BombSquare.BLOW_UP, frame.theGrid[2][2].getBackground());
} |
a6686ce9-8e1d-495e-bd2c-7b7676442219 | @Test
public void taggingAllBombsShouldWinGame()
{
String[][] winGrid = {
{ "LE", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "LE", "RB", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
... |
992696df-e029-41eb-9926-e2e4686e434e | @Test
public void notTaggingAllBombsShouldNotGame()
{
String[][] loseGrid = {
{ "LE", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "LE", "RB", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "B" }... |
3313e368-0350-4e23-8e25-39521c483ff2 | @Test
public void checkToMakeSureFlagIsClearedInCaseOfMassUncover()
{
String[][] tooManyFlagsGrid = {
{ "RE", "LE", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "LE", "RB", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ ... |
8707b763-137d-4ffd-abdd-ac64cbd59918 | @Test
public void oneClickWin()
{
String[][] oneClickWinGrid = {
{ "LE", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "E", "B", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "B" },
};
... |
c4756e1d-0883-4d8d-85ef-21f099f60f29 | @Test
public void NotAllFlaggedAndWin()
{
String[][] oneClickWinGrid = {
{ "LE", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "E", "RB", "E", "E" },
{ "E", "E", "E", "E", "E" },
{ "E", "E", "E", "E", "B" },
... |
4920d031-57b3-41f4-b7d8-06e562c24811 | public Click (int x, int y, int type)
{
super(x, y);
this.type = type;
} |
1ec44116-db19-4234-b9e6-e2464209bce6 | public int getType()
{
return type;
} |
64f2212f-2452-461f-b874-49f3bbbd0496 | public GridFrameTestDouble(String[][] grid, int gridRows, int gridColumns)
{
theGrid = new GridSquare[gridRows][gridColumns];
clicks = new LinkedList<Click>();
numActiveBombs = 0;
int i = 0, j;
for (String[] rows : grid)
{
j = 0;
for (String square : rows)
... |
abc5ddf0-ee0c-4c64-8b5d-57fa0ad66d7e | public void click(int index)
{
Click click = clicks.get(index);
if (click.getType() == Click.LEFT_CLICK)
theGrid[click.y][click.x].leftClick();
else if (click.getType() == Click.RIGHT_CLICK)
theGrid[click.y][click.x].rightClick();
} |
3607e0ae-df7a-4b6d-87df-401c01920148 | public void clickAll()
{
for (Click click : clicks)
{
if (click.getType() == Click.LEFT_CLICK)
theGrid[click.y][click.x].leftClick();
else if (click.getType() == Click.RIGHT_CLICK)
theGrid[click.y][click.x].rightClic... |
9434fcd0-cbe9-4a29-87b8-9fe5e059b118 | @Before
public void setUp()
{
MinesweeperGridFrame frame = createNiceMock(MinesweeperGridFrame.class);
square0 = new GridSquare(0,0);
square0.setParentFrame(frame);
square1 = new GridSquare(1,1);
square1.setParentFrame(frame);
square2 = new GridSquare(2,2);
s... |
b0d7970e-e550-4ae4-bd90-d31ddda74e3c | @Test
public void shouldBeAbleToRetrieveXCoordinate()
{
replayAll();
assertEquals(square0.getXCoordinate(), 0);
assertEquals(square1.getXCoordinate(), 1);
assertEquals(square2.getXCoordinate(), 2);
assertEquals(square3.getXCoordinate(), 3);
} |
459ccd53-db32-47ed-9f11-7d9af7936bd4 | @Test
public void shouldBeAbleToRetrieveYCoordinate()
{
replayAll();
assertEquals(square0.getXCoordinate(), 0);
assertEquals(square1.getXCoordinate(), 1);
assertEquals(square2.getXCoordinate(), 2);
assertEquals(square3.getXCoordinate(), 3);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.