id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
c09b0b03-14fc-4519-9689-6a050947a4a1 | public ColorEnum getColor()
{
return color;
} |
22828c45-f68b-44a5-8f4e-7333f77b4822 | public boolean PieceCanMove(Piece piece, Move move, Board board)
{
boolean r = false;
//If we're dealing with a knight
if (piece.getPiece() == PieceEnum.KNIGHT)
{
//If we're trying to capture
if (board.getBoard()[move.getB().getRow()][move.getB().getCollumn()] != null)
{
//We can only capture ene... |
f6a9807c-ebeb-447e-a6e0-42cc03c01ca0 | public boolean validateKnightMove(Move move)
{
return (move.getB().getCollumn() == move.getA().getCollumn() - 2 && (move.getB().getRow() == move.getA().getRow() + 1 || move.getB().getRow() == move.getA().getRow() - 1))
|| (move.getB().getCollumn() == move.getA().getCollumn() + 2 && (move.getB().getRow() == move.... |
9fe33671-255f-4d73-8a50-b171e911d3a4 | ColorEnum(String colorStr) {
this.colorStr = colorStr;
} |
1bb818a9-b814-4405-a0d4-acd9ac9f1d86 | public String toString() {
return colorStr;
} |
5823441e-8c59-4a55-9483-332a93dc0f64 | public static void main(String[] args) throws ClassNotFoundException
{
Game game1 = new Game();
Move currMove;
Move enemyMove;
System.out.println("Welcome to Knight's Watch!!!");
System.out.println("Waiting for another player to connect...");
String host = args.length > 0 ? args[0] : DEFAULT_HOST;
int p... |
70854a8e-fd68-4a93-8c30-eb09756f686a | PieceEnum(String pieceStr) {
this.pieceStr = pieceStr;
} |
564b762b-ba6e-46f8-9fdb-b47e926d7cbc | public String toString() {
return pieceStr;
} |
222ce3e3-581a-4516-a9f3-42270cee2e52 | public int getRow()
{
return row;
} |
dc52b4db-132a-46f7-8191-12527f1fc272 | public void setRow(int row)
{
this.row = row;
} |
29905cab-d72e-4745-9280-817f8b7f4c65 | public int getCollumn()
{
return collumn;
} |
c769a660-15e8-4bad-b0b3-5c2af8741392 | public void setCollumn(int collumn)
{
this.collumn = collumn;
} |
f1e4b5a5-9ea5-48cf-a843-8afe022efc72 | public BoardPosition(int row, int collumn)
{
this.row = row;
this.collumn = collumn;
} |
218019d5-b468-4620-841d-39b2d9f744fc | public boolean isOutOfBounds()
{
return row < 0 || row > 6 || collumn < 0 || collumn > 6;
} |
e66cccc1-d6fa-461e-b7d7-39c3928c1108 | public String toString()
{
ArrayList<String> colNames = new ArrayList<String>();
colNames.add("a");
colNames.add("b");
colNames.add("c");
colNames.add("d");
colNames.add("e");
colNames.add("f");
String r = "";
r += 6 - row + colNames.get(collumn);
return r;
} |
87471279-f353-4291-9cbf-b856390a22e2 | public Piece(ColorEnum color, PieceEnum piece)
{
this.color = color;
this.piece = piece;
} |
b72fc693-bc67-452c-9f25-79f7648f409b | public String toString()
{
String output;
output = color.toString() + piece.toString();
return output;
} |
2ddc88b6-33e8-4ff4-9fea-75b339bcc9d1 | public ColorEnum getColor()
{
return color;
} |
7c78acf6-1036-40d0-a44a-65a4bac13a27 | public PieceEnum getPiece()
{
return piece;
} |
c6d13ec4-80ef-4a7f-9d41-553790845ad5 | public void setCurrPlayer(ColorEnum color)
{
if (color == ColorEnum.WHITE)
{
this.currPlayer = player1;
}
else
{
this.currPlayer = player2;
}
} |
9601cfb9-acf2-4aa2-a4af-cf7b34673b38 | public Player getPlayer1()
{
return player1;
} |
486653fe-d6d6-4d1c-b954-8aa1ee6f6e92 | public void setPlayer1(Player player1)
{
this.player1 = player1;
} |
71a3a9b3-5b93-4f72-93de-badc4fe400b6 | public Player getPlayer2()
{
return player2;
} |
9ed1ee4d-30f2-47de-8424-1a90315488e8 | public void setPlayer2(Player player2)
{
this.player2 = player2;
} |
82f32663-e3ed-4ae1-91cc-7d9a56ae0731 | public Game()
{
board = new Board();
player1 = new Player(ColorEnum.WHITE, board);
player2 = new Player(ColorEnum.BLACK, board);
} |
1056661f-b78e-40b1-8710-568b4cf41e99 | public Board getBoard()
{
return board;
} |
b4db8bdc-7e29-4e89-864a-cfffa136efd3 | public Move makeMoveForCurrentPlayer()
{
return currPlayer.makeMove();
} |
72f2dfd1-01e8-461b-b56e-d8e49b91d050 | public GameStatus getStatus()
{
GameStatus r = GameStatus.CONTINUE;
//Have any pawns reached the enemy wall?
for (int i = 0; i < 6; i++)
{
//Check the White pawns
if (board.getBoard()[0][i] != null)
{
if (board.getBoard()[0][i].getPiece() == PieceEnum.PAWN)
{
r = GameStatus.WHITEWINS;
... |
d4f3d807-d9e1-431d-a2f6-9faf61309fe7 | public ChatWindow() {
super();
initGUI();
} |
6069acda-d3c1-4463-a1c8-84fa22789b38 | public ChatWindow(Socket s, String l) {
socket = s;
login = l;
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setTitle("Java Instant Chat - Server");
initGUI();
} |
67bd0dff-7e43-4429-81d6-bcf9ff1f07f6 | private void initGUI() {
try {
out = new PrintWriter(socket.getOutputStream());
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
sdf = new SimpleDateFormat("HH:mm");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
{
jPanel1 = new JPanel();
getContentPane()... |
7ca39d8e-9a4f-4415-bab8-9db290b255fb | public void actionPerformed(ActionEvent evt) {
jButton1ActionPerformed(evt);
} |
f8043dea-eafe-4223-b29a-00c306df519c | private void jButton1ActionPerformed(ActionEvent evt) {
if (jTextField1.getText().isEmpty()) {
JOptionPane.showMessageDialog(this, "Please type in a message.");
}
else {
out.println(jTextField1.getText());
out.flush();
out.println(login);
out.flush();
cal = Calendar.getInstance();
jTex... |
7047df59-bb86-4614-8b08-9fa1b5995907 | public Accept(ServerSocket ss){
socketserver = ss;
} |
a9305a4d-ae99-4414-938b-ac4c9fba0676 | public void run() {
try {
while(true){
socket = socketserver.accept();
t1 = new Thread(new Auth(socket));
t1.start();
}
} catch (IOException e) {
System.err.println("Erreur serve... |
4878b4c4-73c8-496f-84da-136f94b107d2 | public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Start inst = new Start();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
inst.setTitle("Java Instant Chat Server");
}
});
} |
4a04f84d-f8af-451a-b3ef-d9cd6eb6f7f8 | public void run() {
Start inst = new Start();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
inst.setTitle("Java Instant Chat Server");
} |
cb9cf549-5831-44b6-b6ed-d49ff2e2326f | public Start() {
super();
initGUI();
} |
468affc8-fcfb-48f9-b149-438deb047403 | private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
{
jPanel2 = new JPanel();
getContentPane().add(jPanel2, BorderLayout.SOUTH);
jPanel2.setPreferredSize(new java.awt.Dimension(384, 66));
{
jButton1 = new JButton();
jPanel2.add(jButton1);
jBu... |
e74d8e0d-196b-423f-959f-78cd320dc67a | public void actionPerformed(ActionEvent evt) {
jButton1ActionPerformed(evt);
} |
37d53b44-115a-4fad-a4fa-aafa0677492b | private void jButton1ActionPerformed(ActionEvent evt) {
try {
ss = new ServerSocket(2009);
System.out.println("Server started on "+ss.getLocalPort()+". Waiting for clients to connect.");
t = new Thread(new Accept(ss));
t.start();
this.dispose()... |
ee94a7a7-d77a-4dd3-ac64-ea6db5e65554 | public Statement Connect() {
try {
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/JavaInstantChat";
String user = "postgres";
String passwd = "Supinf0";
Connection conn = DriverManager.getConnection(url, user, passwd);
state = con... |
99f6c6a7-5e53-454f-b4fb-d94ad4e9c4e1 | public Auth(Socket s){
socket = s;
} |
b5cd6bd3-b8b8-46ed-8956-bd648641b780 | public void run() {
try {
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream());
login = in.readLine();
password = in.readLine();
DbConnect DBC = new DbConnect();
stat... |
a7fc9f87-f87b-4f17-8a1b-0514f02d3d14 | public ChatWindow(Socket s, String l) {
socket = s;
login = l;
} |
e89926c5-2c0c-4658-9191-2061582cb562 | private void initGUI() {
try {
out = new PrintWriter(socket.getOutputStream());
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
sdf = new SimpleDateFormat("HH:mm");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
{
jPanel1 = new JPanel();
getContentPane()... |
2538bf98-95ad-41db-8670-b683d7768c68 | public void actionPerformed(ActionEvent evt) {
jButton1ActionPerformed(evt);
} |
cbe7ee3b-06ae-4f87-a093-954e1f8b71f1 | private void jButton1ActionPerformed(ActionEvent evt) {
if (jTextField1.getText().isEmpty()) {
JOptionPane.showMessageDialog(this, "Please type in a message.");
}
else {
out.println(jTextField1.getText());
out.flush();
out.println(login);
out.flush();
cal = Calendar.getInstance();
jText... |
06d8269d-623e-461c-86e7-dcd6843baa0d | public void run() {
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setTitle("Java Instant Chat - Client");
initGUI();
} |
e22efbe8-203f-46ce-86b8-fd7781a07e5a | public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Welcome inst = new Welcome();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
inst.setTitle("Java Instant Chat Client");
}
});
} |
15b2c3f3-83bd-4519-ae63-38e9d2381dce | public void run() {
Welcome inst = new Welcome();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
inst.setTitle("Java Instant Chat Client");
} |
561f739b-b131-4796-b6c0-890cf0de0791 | public Welcome() {
super();
initGUI();
} |
f2e61584-7d4a-4303-8b8a-0257b7325d66 | private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
{
jPanel1 = new JPanel();
getContentPane().add(jPanel1, BorderLayout.NORTH);
jPanel1.setPreferredSize(new java.awt.Dimension(384, 42));
{
jLabel1 = new JLabel();
jPanel1.add(jLabel1);
jLabel... |
9f2428b1-7874-43d6-8848-e81149583222 | public void actionPerformed(ActionEvent evt) {
jButton1ActionPerformed(evt);
} |
a66e664a-9044-4a50-9e10-1b4db235f741 | public void actionPerformed(ActionEvent evt) {
jButton2ActionPerformed(evt);
} |
81009ce9-2331-4384-90c6-fcc60bf7b7c5 | private void jButton1ActionPerformed(ActionEvent evt) {
try {
socket = new Socket("127.0.0.1",2009);
login = jTextField1.getText();
password = new String(jPasswordField1.getPassword());
LoginCheck lc = new LoginCheck(socket);
IDcheck = lc.Check(login, p... |
9829d202-4b10-48ca-acb5-321585768379 | private void jButton2ActionPerformed(ActionEvent evt) {
this.dispose();
} |
f959176b-1714-470b-bd9f-058d2c7438eb | public LoginCheck(Socket s){
socket = s;
} |
2c2d7d2a-0da3-4f71-b8ab-2be887055b9b | public boolean Check(String login, String password) {
try {
out = new PrintWriter(socket.getOutputStream());
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.println(login);
out.flush();
out.println(password);
out.flush();
j = Integer.parseInt(in.readLine());
switch... |
43da4de0-d990-4bf3-9690-87fe9bc9ca81 | public static CellStyle style(Workbook workbook) {
Font font = font(workbook);
CellStyle style = workbook.createCellStyle();
style.setFont(font);
return style;
} |
d014533a-f929-4d89-ad44-6353f5357e4a | public static Font font(Workbook workbook) {
Font font = workbook.createFont();
font.setColor(HSSFFont.COLOR_RED);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 15);
return font;
} |
3f8d0f82-6ef2-46c8-81cc-28da11b1d5bf | public boolean isInterupt() {
return isInterupt;
} |
7916831f-0f29-4b6b-a3c4-f91890e10752 | public void setInterupt(boolean isInterupt) {
this.isInterupt = isInterupt;
} |
0993b8ff-5f0e-4c7c-92a2-908a393100a0 | public Highlight(int rowIndex, int cellIndex) {
this.rowIndex = rowIndex;
this.cellIndex = cellIndex;
} |
1bfe9cba-9002-44d8-b1c7-450522ae9f46 | public int getRowIndex() {
return rowIndex;
} |
ddbd4cad-e615-459b-a2ea-c70e9706b3c1 | public int getCellIndex() {
return cellIndex;
} |
0929e64a-bf71-4a4c-9820-97b64643b56a | public ExcelServiceImpl(String path) {
this.filePath = path;
} |
3793fde2-d6bc-4b9d-9767-ae8d95963dfe | public ExcelServiceImpl(String path, int sheetNum) {
this.filePath = path;
this.sheetNum = sheetNum;
} |
af7027b3-3bd6-417a-8577-d40f10b7b9fc | @Override
public List<Cell> getDataAtColumn(int column) throws Exception {
Workbook workbook = _createWorkbook();
Sheet sheet = workbook.getSheetAt(sheetNum);
return ExcelUtils.getCell(sheet, column);
} |
ac45d32f-9937-4b87-acac-2d1029b4ebfb | @Override
public void highlight(List<Highlight> highlights) throws Exception {
Workbook workbook = _createWorkbook();
for (Highlight highlight : highlights) {
_setHighlight(workbook, highlight);
}
FileOutputStream out = new FileOutputStream(new File(filePath));
... |
bb344b67-3677-4067-add7-306880455310 | private Workbook _createWorkbook() throws Exception {
InputStream is = new FileInputStream(new File(filePath));
if (filePath.toLowerCase().endsWith("xlsx")) {
return new XSSFWorkbook(is);
} else if (filePath.toLowerCase().endsWith("xls")) {
return new HSSFWorkbook(is);
... |
77ba8c37-c54e-4b32-96c2-4e773b8e23ab | private void _setHighlight(Workbook workbook, Highlight highlight) throws Exception {
Sheet sheet = workbook.getSheetAt(sheetNum);
int rowIndex = highlight.getRowIndex();
int cellIndex = highlight.getCellIndex();
Cell cell = sheet.getRow(rowIndex).getCell(cellIndex);
cell.setC... |
25a6ecc9-4a51-43ad-9192-bbc624b3f2e0 | @Override
public ExcelService path(String path) {
this.filePath = path;
return this;
} |
b4a81cce-fac8-4470-9519-d36669b33d13 | public DuplicateStrategyCheckServiceImpl(ExcelService excelService) {
this.excelService = excelService;
} |
55571c0c-1beb-4f33-9bb3-e2948288bd27 | public void checkDuplicate() throws Exception {
List<Highlight> highlights = _getHighlights();
excelService.path(Contants.SYMBOLS_XLSX).highlight(highlights);
} |
4abf309e-54c6-4521-a1d9-b30572d6464f | private List<Highlight> _getHighlights() throws Exception {
List<Integer> listYesNo = ExcelUtils.getCellValueAsInteger(excelService.getDataAtColumn(Contants.CHECK_DUPLICATE_COLUMN));
List<Highlight> highlights = new ArrayList<Highlight>();
for (int i = 0; i < listYesNo.size(); i++) {
if (i == 1) {
highlig... |
29406825-d0e3-44c1-a89f-c3a2671b7984 | List<Cell> getDataAtColumn(int column) throws Exception; |
3d05b613-4325-46fa-9a98-44252df9d6f5 | void highlight(List<Highlight> highlights) throws Exception; |
6cdcd777-d899-411f-8159-347a4bb1354b | ExcelService path(String path); |
5a42a345-4a9f-4c4a-8d49-1dc1edbbeb75 | public MorningAfternoonStrategyCompareService(ExcelService excelService) {
this.excelService = excelService;
} |
b6da6747-108e-447d-b7d5-66ec7345f947 | public void compareMorningAfternoon() throws Exception {
List<Highlight> highlights = _getHighlightList();
excelService.highlight(highlights);
} |
6a6b3bfc-efc5-4a9c-bd18-2a96774adc8d | private List<Highlight> _getHighlightList() throws Exception {
List<String> firstColumn = ExcelUtils.getCellValueAsString(excelService.getDataAtColumn(0));
List<String> secondColumn = ExcelUtils.getCellValueAsString(excelService.getDataAtColumn(1));
List<Highlight> highlights = new ArrayList<Hi... |
f92d8c27-4bd2-4414-9303-8a0218fb97e9 | void checkDuplicate() throws Exception; |
b6ac228b-c0fd-4b82-bd1c-a216c944d32c | public static List<Cell> getCell(Sheet sheet, int column) {
List<Cell> cells = new ArrayList<Cell>();
Iterator<Row> rowIter = sheet.rowIterator();
while (rowIter.hasNext()) {
Row row = (Row) rowIter.next();
cells.add(row.getCell(column));
}
ret... |
56c0f653-5f20-4e14-b1ac-036c29d71ec6 | public static List<String> getCellValueAsString(List<Cell> cells) {
List<String> values = new ArrayList<String>();
for (Cell cell : cells) {
if (cell == null) {
break;
}
values.add(cell.getStringCellValue().toUpperCase());
}
return va... |
bea65f94-ba47-4d6c-8aa4-e25f53d1c623 | public static List<Integer> getCellValueAsInteger(List<Cell> cells) {
List<Integer> values = new ArrayList<Integer>();
for (Cell cell : cells) {
if (cell == null) {
continue;
}
try {
values.add((int) cell.getNumericCellValue());
} catc... |
c4dbbb91-69f8-4b53-b163-516ffad4b13b | public StrategyFilterView(String title) {
super(title);
_addListener();
_buildUI();
setSize(700, 150);
setLocation(400, 300);
} |
340d310b-b84b-4fce-9649-c1dca670f30a | @Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.morningAfternoonCompareBtn) {
try {
status.setText(" - Processing ");
final ThreadInterceptor ti = new ThreadInterceptor();
Thread th = new Thread(new Runnable() {
@Override
public void run() {
for (i... |
905cc851-7eb7-4735-a28b-18414574284a | @Override
public void run() {
for (int i = 0; i < 30; i++) {
if (ti.isInterupt()) {
break;
}
status.setText(status.getText() + "->");
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} |
8bd94ba1-051d-4d18-80e0-9ca47d86d60c | @Override
public void run() {
for (int i = 0; i < 30; i++) {
if (ti.isInterupt()) {
break;
}
status.setText(status.getText() + "->");
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} |
82b36421-b7df-484f-8dd6-5144c655ecd0 | @Override
public void run() {
for (int i = 0; i < 30; i++) {
if (ti.isInterupt()) {
break;
}
status.setText(status.getText() + "->");
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} |
a6edb85d-8a75-4f4d-a62a-0baaf88a83c6 | private void _buildUI() {
this.status.setForeground(Color.DARK_GRAY);
Font font = new Font("", Font.BOLD, 14);
this.status.setFont(font);
this.morningAfternoonCompareBtn.setBackground(Color.DARK_GRAY);
this.morningAfternoonCompareBtn.setForeground(Color.ORANGE);
this.checkDuplicateBLightBtn.setBackground(C... |
4e3451dc-7044-421f-a93a-e620b14a37f5 | private void _addListener() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
StrategyFilterView.this.dispose();
}
});
this.morningAfternoonCompareBtn.addActionListener(this);
this.checkDuplicateBLightBtn.addActionListener(this);
this.checkDuplicateVTradeBtn.addAc... |
b6456869-bc24-4846-942a-8f6481914dfd | public void windowClosing(WindowEvent e) {
StrategyFilterView.this.dispose();
} |
064b9fe4-2446-4047-8a0a-59cb27cf66f8 | public static void main(String[] args) {
StrategyFilterView view = new StrategyFilterView("© minh.nguyen vnds");
view.setVisible(true);
} |
fcaa5d29-07f2-4fab-ae89-e7894e621c7a | @Before
public void setUp() {
service = new ExcelServiceImpl(path);
} |
0b90cad9-f8d9-4ccf-8994-73b18fa9e911 | @Test
public void testGetDuplicateData() throws Exception {
service = new ExcelServiceImpl(path, 0);
List<Cell> cells = service.getDataAtColumn(5);
List<Integer> values = ExcelUtils.getCellValueAsInteger(cells);
System.out.println(values);
System.out.println(values.size())... |
1d090db5-3d91-4f5d-97a6-4fe89564b56d | @Test
public void testGetColumnData() throws Exception {
List<Cell> cells = service.getDataAtColumn(0);
for (Cell cell : cells) {
System.out.println(cell.getStringCellValue());
}
} |
b4559ea5-bde9-44f9-bd86-899d1677aa04 | @Test
public void testHighlight() throws Exception {
Highlight[] highlightArr = new Highlight[] { new Highlight(1, 0) };
service.highlight(Arrays.asList(highlightArr));
} |
e5179c03-116a-46d8-bb98-b0b3056a9a38 | @Before
public void setUp() {
excelService = new ExcelServiceImpl(filePath);
service = new MorningAfternoonStrategyCompareService(excelService);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.