id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
a62de0b4-59ba-4fc6-8359-f6b3c2263608 | public boolean isNotMine(int column, int row) { //vrati true, pokud je zadane policko prazdne nebo je na nem souperova figurka
if(isEnemy(player,column, row) || isFree(column, row)) {
return true;
}
else {
return false;
}
} |
e9460f3c-5caf-4cf5-b437-87f21baa43d9 | public boolean castling(boolean type) { //vrati false, pokud rosada type nebyla mozna;type = true pro kratkou
//int ij = 0;
if(player){
if(type){
if(board[4][0] != null && board[4][0] instanceof King && !board[4][0].moved && board[7][0] != null && board[7][0] instanceof Rook ... |
02779de3-b424-4148-b2b3-10f3df46a98a | public boolean command() { //nacte prikaz z klavesnice a pokud je mozny, provede ho a vrati true
Scanner inp = new Scanner(System.in);
if(player) {
System.out.println("Hraje bily.");
}
else {
System.out.println("Hraje cerny.");
}
System.out.println... |
73aa0618-7381-4923-a50e-80591494ec93 | private char letterToNumber(char _letter) { //prevede pismena a-h na cislice 1-8
char[] lettersLC = {'a','b','c','d','e','f','g','h'};
char[] lettersUC = {'A','B','C','D','E','F','G','H'};
char[] numbers = {'1','2','3','4','5','6','7','8'};
for (int i = 0; i < 8; i++){
if(_le... |
4f84e561-beed-416d-8e33-7b838b64ae58 | private void save() { //zapise do souboru, kdo je na tahu a pozice vsech figurek
try{
Scanner inp = new Scanner(System.in);
System.out.println("Zadej jmeno souboru:");
FileWriter fstream = new FileWriter(inp.nextLine() + ".save");
BufferedWriter out = new Buffere... |
2e17bd88-e0ca-4804-8e59-1a6235fe6c09 | private void load() { //nacte hru ze souboru
Scanner inp = new Scanner(System.in);
System.out.println("Zadej jmeno souboru:");
for (int _row = 0; _row < 8; _row++) { //projde celou sachovnici...
for (int _column = 0; _column < 8; _column++) {
this.board[_row][_column]... |
edc4c7a6-85a1-40eb-ac2d-96daa56661f4 | private void loadPiece(String com) { //vytvori na sachovnici instanci dane figurky
int column = Character.getNumericValue(com.charAt(1));
int row = Character.getNumericValue(com.charAt(2));
boolean moved;
if(com.charAt(3) == 'T') {
moved = true;
}
else {
... |
89021073-ccac-40d4-aef6-d5e8dc5d433d | public void newGame() { //zahaji novou hru
this.player = false;
fillBoardColor();
for (int _row = 0; _row < 8; _row++) { //projde celou sachovnici...
for (int _column = 0; _column < 8; _column++) {
this.board[_row][_column] = null;
}
}
this... |
cd73e82c-722a-43b4-8193-ad43ff19d08c | public void print() { //vytiskne sachovnici a figurky do konzole
for(int row = 7; row >= 0; row--) {
System.out.print(row+1 + " ");
for(int column = 0;column < 8;column++) {
System.out.print(fields[column][row]);
if(board[column][row] != null) {
... |
cbdcca16-0134-43ba-a099-5c5c007777d8 | private void fillBoardColor() { //naplni pole barev jednotlivych policek na sachovnici
boolean switching = false; //na stridani barev v radku
for (int _row = 0; _row < 8; _row++) { //projde celou sachovnici...
for (int _column = 0; _column < 8; _column++) {
if (switching == t... |
b68012a4-8d97-4720-85d6-2d7d225ed562 | public boolean stillPlaying() {
return this.stillPlaying;
} |
9b2b7673-8334-45cd-9827-fe3ede971611 | public void changePlayer() { //zmeni hrace
this.player = !this.player;
} |
267d8065-bda1-4fb9-b577-bf984dd06f45 | public boolean isEndGame(Chessman king) { //otestuje, zda-li neni dana situace remiza pripadne mat
boolean draw = !isChecked();
for (int _row = 0; _row < 8; _row++) { //projde celou sachovnici...
for (int _column = 0; _column < 8; _column++) {
if(this.board[_column][_row] != ... |
3a5c1c3a-942a-4ae9-99aa-4714818fa2a3 | public boolean isChecked() { //zkontroluje, zda-li neni kral hrace, ktery je prave na tahu, v sachu
int columnKing = -1, rowKing = -1;
for (int _row = 0; _row < 8; _row++) { //projde celou sachovnici...
for (int _column = 0; _column < 8; _column++) {
if ((this.board[_column][... |
47aa7427-fb81-4d7c-b63a-2ffcc03f850e | private String getPlayer(){
if(player) {
return "true";
}
else{
return "false";
}
} |
730dce69-2f61-40a0-aa7b-e511488b8084 | public Chessman getKing() {
if(player == true) {
return whiteKing;
}
else {
return blackKing;
}
} |
c2a8a969-20ad-41a8-9a96-5729d7477d59 | Rook(ChessBoard boardRef,boolean color, int row, int column,boolean moved) {//konstruktor pro nacteni nove hry/hry ze souboru
super(boardRef, color, row, column,moved);
} |
17941392-4ab6-400d-933e-9a5c2c816ff8 | Rook(Chessman copy, int column, int row) {//konstruktor k presouvani po sachovnici
super();
this.color = copy.color;
this.row = row;
this.column = column;
this.ref = copy.ref;
this.moved = true;
System.out.println(this.moved);
} |
7a196059-4dd6-4aff-abac-a5a644ea98b2 | @Override public boolean inRange(int column, int row) { //vrati true, pokud je pole [row][column] v dosahu figury
if(column == this.column) {
if(row > this.row) {
for(int i = 1;i < row-this.row; i++) {
if(!ref.isFree(this.column, this.row+i)) {
... |
3b40fd52-b8e2-43b2-91c3-1f086f8b097d | @Override public boolean move(boolean really,int column, int row){//vrati true, pokud je tah na pole [column][row] mozny. pokud je navic argument really = true, tah se i provede
if(inRange(column, row)&& ref.isNotMine(column, row)){
Rook backUp;
Chessman ten;
backUp = this;
... |
7d96cbe8-f7d4-4a07-97fc-75611c3d90a7 | @Override public String toString() {
if (this.color == true) {
return "R";
}
else {
return "r";
}
} |
5fb66f71-577d-4592-b61f-8b3dbea78910 | public static void main(String[] args) { //hlavni trida s jednoduchou smyckou
ChessBoard a = new ChessBoard();
a.newGame();
a.changePlayer();
while(a.stillPlaying()) {
a.print();
if(a.command()){
a.changePlayer();
//System.out.print... |
d3c3221a-90cc-4870-9798-82451118cbb2 | King(ChessBoard boardRef,boolean color, int row, int column, boolean moved) {//konstruktor pro nacteni nove hry/hry ze souboru
super(boardRef, color, row, column, moved);
} |
0634a594-3baa-427a-8c65-94ea95e8e5f1 | King(Chessman copy, int column, int row) {//konstruktor k presouvani po sachovnici
super();
this.color = copy.color;
this.row = row;
this.column = column;
this.ref = copy.ref;
this.moved = true;
System.out.println(this.moved);
} |
ff4bdc3f-3d84-48b0-b613-25835b6e043b | @Override public boolean move(boolean really,int column, int row){//vrati true, pokud je tah na pole [column][row] mozny. pokud je navic argument really = true, tah se i provede
if(inRange(column, row)&& ref.isNotMine(column, row)){
King backUp;
Chessman ten;
backUp = this;
... |
72966875-e544-4a87-a32e-743107454a26 | @Override public boolean inRange(int column, int row) { //vrati true, pokud je pole [row][column] v dosahu figury
if((Math.abs(column - this.column) <= 1) && (Math.abs(row - this.row) <= 1)) {
if(ref.isFree(column, row) || ref.isEnemy(this.color,column,row)) {
return true;
... |
2f43c989-1cff-4e7a-9f7f-8cc2403fe70a | @Override public String toString() {
if (this.color == true) {
return "X";
}
else {
return "x";
}
} |
104c508b-926c-49da-ae15-e3af9093c83b | Chessman(ChessBoard boardRef,boolean color, int column, int row, boolean moved) { //konstruktor
this.color = color;
this.column = column;
this.row = row;
this.ref = boardRef;
this.moved = moved;
} |
6ea75f3e-14a3-4591-85c9-bd2f3841af34 | Chessman() { //defaultni konstruktor
super();
} |
9a9e4dcc-5da1-4d53-9d05-c38e6082ab23 | public boolean isDraw() {
return false;
} |
1424bd54-d6f9-4259-961c-8c1b61d99d04 | public boolean isCheckmate() {
return false;
} |
de988a1e-0234-46d7-8f64-dcfa05f83a13 | public abstract boolean move(boolean really,int column, int row); //provede tah na policko [column,row], nebo vrati false, pokud tah neni mozny, pokud je really = false, tah se neprovede, pozue se zjisti, zda-li je mozny |
3d085371-c3e8-4e7d-888f-ffd3760c60e5 | public abstract boolean inRange(int column, int row); |
69f5f9f5-bb1b-4373-a1ba-fec6a6bea335 | @Override public abstract String toString(); |
01d2123d-0382-403d-a67b-dd1840cdae64 | public int getColumn() {
return this.column;
} |
91e330b1-def9-4418-83af-c4d40803ef93 | public int getRow() {
return this.row;
} |
4f20d5f5-0c52-44f2-b130-0285ebf735a1 | public boolean getPlayer() {
return this.color;
} |
4315cd9d-1ce7-42f5-8075-d1c81e95f34b | public boolean getMoved(){
return this.moved;
} |
1de84dd7-0e57-4ac7-badd-d1daf600fef6 | Bishop(ChessBoard boardRef,boolean color, int row, int column,boolean moved) {//konstruktor pro nacteni nove hry/hry ze souboru
super(boardRef, color, row, column,moved);
} |
ae2d27d9-e513-476e-a27f-9f8ac636521e | Bishop(Chessman copy, int column, int row) {//konstruktor k presouvani po sachovnici
super();
this.color = copy.color;
this.row = row;
this.column = column;
this.ref = copy.ref;
} |
3a8831de-86ac-43d7-b5ed-df6c2a9e6ab5 | @Override public boolean move(boolean really,int column, int row){//vrati true, pokud je tah na pole [column][row] mozny. pokud je navic argument really = true, tah se i provede
if(inRange(column, row)&& ref.isNotMine(column, row)){
Bishop backUp;
Chessman ten;
backUp = this;... |
fa30c6fb-8be6-4a1b-a9be-3cad81493b11 | @Override public boolean inRange(int column, int row) { //vrati true, pokud je pole [row][column] v dosahu figury
if(Math.abs(this.column - column) == Math.abs(this.row - row)) {
//System.out.println("ok");
if(this.column < column && this.row < row) {
for(int i = 1; i < (... |
15ef6f39-ff9c-4665-be52-98a63adc0ddb | @Override public String toString() {
if (this.color == true) {
return "B";
}
else {
return "b";
}
} |
bd36633d-f319-4125-bdd9-82583bf4e120 | Knight(ChessBoard boardRef,boolean color, int row, int column,boolean moved) { //konstruktor pro nacteni nove hry/hry ze souboru
super(boardRef, color, row, column, moved);
} |
128bc039-952b-4579-ae9a-4d92f94978b6 | Knight(Chessman copy, int column, int row) { //konstruktor k presouvani po sachovnici
super();
this.color = copy.color;
this.row = row;
this.column = column;
this.ref = copy.ref;
} |
acf16991-6e64-432d-91b8-ce547520e085 | @Override public boolean inRange(int column, int row) { //vrati true, pokud je pole [row][column] v dosahu figury
if (Math.abs(column - this.column) == 2 && Math.abs(row - this.row) == 1) {
return true;
}
if (Math.abs(row - this.row) == 2 && Math.abs(column - thi... |
83e0a355-9c6c-493d-b285-49d483c33d8f | @Override public boolean move(boolean really,int column, int row){ //vrati true, pokud je tah na pole [column][row] mozny. pokud je navic argument really = true, tah se i provede
if(inRange(column, row)&& ref.isNotMine(column, row)){
Knight backUp;
Chessman ten;
backUp = this... |
a1470f7e-25c6-412a-bca2-8b0eb9bbe2b9 | @Override public String toString() {
if (this.color == true) {
return "K";
}
else {
return "k";
}
} |
d3e5a8bc-08ec-43ed-9f09-d37dd88b7755 | @GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
return "Hello Jersey";
} |
5056e364-26b3-4ccf-9480-2ca4a71c5a73 | @GET
@Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
} |
a59cbc8b-94da-4a90-b981-202f8d2a6649 | @GET
@Produces(MediaType.TEXT_HTML)
public String sayHtmlHello() {
return "<html> " + "<title>" + "Hello Jersey" + "</title>"
+ "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";
} |
74ba5670-e53e-443e-8361-099546fd2f77 | @GET
@Produces(MediaType.APPLICATION_JSON)
public String sayJsonHello() {
return "{\"respuesta\": \"Hello Jersey\"}";
} |
8e1e660f-2ad5-4bb4-8f1e-bd4efd1e4e3e | @GET
@Produces(MediaType.TEXT_XML)
public List<Todo> getTodosBrowser() {
List<Todo> todos = new ArrayList<Todo>();
todos.addAll(TodoDao.instance.getModel().values());
return todos;
} |
04717776-f09c-4500-b926-31de821e8347 | @GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<Todo> getTodos() {
List<Todo> todos = new ArrayList<Todo>();
todos.addAll(TodoDao.instance.getModel().values());
return todos;
} |
9b97194a-6571-4392-9704-e4e5128ae682 | @GET
@Path("count")
@Produces(MediaType.TEXT_PLAIN)
public String getCount() {
int count = TodoDao.instance.getModel().size();
return String.valueOf(count);
} |
dc6d2a74-da16-4441-b47a-dfa853c01054 | @POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void newTodo(@FormParam("id") String id,
@FormParam("summary") String summary,
@FormParam("description") String description,
@Context HttpServletResponse servletResponse) throws IOException {
Todo todo = new Todo(... |
adbd7b20-1095-4511-82e5-5a253034a007 | @GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Todo getTodo() {
Todo todo = TodoDao.instance.getModel().get(id);
if (todo == null)
throw new RuntimeException("Get: Todo with " + id + " not found");
return todo;
} |
a71cecde-99f4-42a0-a82f-e5ea9204ca51 | @GET
@Produces(MediaType.TEXT_XML)
public Todo getTodoHTML() {
Todo todo = TodoDao.instance.getModel().get(id);
if (todo == null)
throw new RuntimeException("Get: Todo with " + id + " not found");
return todo;
} |
f36a4947-581d-4e95-880d-f0e781dbdc9e | @PUT
@Consumes(MediaType.APPLICATION_XML)
public Response putTodo(JAXBElement<Todo> todo) {
Todo c = todo.getValue();
return putAndGetResponse(c);
} |
1fdd30e3-ac8a-48b6-9b2b-e83d27ec11fe | @DELETE
public void deleteTodo() {
Todo c = TodoDao.instance.getModel().remove(id);
if (c == null)
throw new RuntimeException("Delete: Todo with " + id + " not found");
} |
f01d6d6b-197e-433d-876e-83bc863deb4f | private Response putAndGetResponse(Todo todo) {
Response res;
if (TodoDao.instance.getModel().containsKey(todo.getId())) {
res = Response.noContent().build();
} else {
res = Response.created(uriInfo.getAbsolutePath()).build();
}
TodoDao.instance.getModel().put(todo.getId(), todo);
return res;
} |
45389d0f-be16-4895-ab0a-2a3d49c4c528 | public static void main(String[] args) {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
// Fluent interfaces
System.out.println(service.path("rest").path("hello").accept(MediaType.TEXT_PLAIN).get(Clien... |
52310863-5421-475f-84c9-a7af177bb33f | private static URI getBaseURI() {
return UriBuilder.fromUri("http://localhost:8080/hellorest").build();
} |
c1d8d351-7d0f-49cc-bd21-e3ed1156e358 | private TodoDao() {
Todo todo = new Todo("1", "Learn REST");
todo.setDescription("Read http://www.vogella.com/articles/REST/article.html");
contentProvider.put("1", todo);
todo = new Todo("2", "Do something");
todo.setDescription("Read complete http://www.vogella.com");
contentProvider.put("2", todo);
} |
6755fcb6-181d-43ab-b936-0cde42be8e41 | public Map<String, Todo> getModel() {
return contentProvider;
} |
8ec0dbc5-176d-4a88-97b8-04645f78d68d | public Todo() {
} |
cc4d6f1b-f42b-44e3-8621-b99b2131ddd5 | public Todo(String id, String summary) {
this.id = id;
this.summary = summary;
} |
41e5c4be-3ee5-43ee-bddd-59cbf4b22fe9 | public String getId() {
return id;
} |
2a65f48b-8c6d-442f-a248-6a3d61c81267 | public void setId(String id) {
this.id = id;
} |
108ddc3f-69dd-415a-af1f-d29cb814eac7 | public String getSummary() {
return summary;
} |
7c08d41e-97dd-4b28-9bd3-d0fc47b8342a | public void setSummary(String summary) {
this.summary = summary;
} |
609480df-caa9-4f8f-842c-190a3185eddd | public String getDescription() {
return description;
} |
0c8f0908-21ed-4b38-a508-15877ca8f126 | public void setDescription(String description) {
this.description = description;
} |
346a418a-30cc-410b-bc3a-af85ff38b2fb | public abstract int getHealth(); |
e551cd94-f027-47e9-8812-f3f52e80ab6e | public abstract int getStrength(); |
eb2e5f10-ad45-410b-b775-9954ccb5c1f8 | public abstract int getDexterity(); |
716f1235-b45f-4299-ada5-648591f939e9 | public abstract int getIntelligence(); |
0b3f5267-904f-4353-af37-9483f6f143de | public abstract int attack(); // probably take some arguments from weapon to increase damage.... |
afa1d9b1-1463-428c-be2b-1618d3d59cdf | public Light(){
} |
05d43d1d-714a-40ca-bf72-5d9393e7cbfe | @Override
public int getHealth() {
// TODO Auto-generated method stub
return hp;
} |
a1ebc41b-b23a-4ecd-93da-0fd698f047ac | @Override
public int getStrength() {
// TODO Auto-generated method stub
return muscle;
} |
ed862f25-e69c-49d8-8f2b-007f7ebd6f49 | @Override
public int getDexterity() {
// TODO Auto-generated method stub
return dex;
} |
358f1790-5bb4-4e99-b3ff-e2200277b125 | @Override
public int getIntelligence() {
// TODO Auto-generated method stub
return intel;
} |
d78fd2f9-f2e4-4428-bdad-5ab62e58718f | @Override
public int attack() {
// TODO Auto-generated method stub
return 0;
} |
4906f691-6b1c-463e-9c3e-2e28a8ff1253 | public Medium(){
} |
eb4534b8-d61f-40a5-b716-186ada410159 | @Override
public int getHealth() {
// TODO Auto-generated method stub
return hp;
} |
f38bbec2-e2f8-4094-b0d9-4f4587c8723c | @Override
public int getStrength() {
// TODO Auto-generated method stub
return muscle;
} |
07cc68c5-a872-4e9f-8ef2-f693f123789a | @Override
public int getDexterity() {
// TODO Auto-generated method stub
return dex;
} |
2547e1de-7a10-474a-a625-0208b91212e1 | @Override
public int getIntelligence() {
// TODO Auto-generated method stub
return intel;
} |
78c8232f-ec39-40e6-97ee-e0011adde762 | @Override
public int attack() {
// TODO Auto-generated method stub
return 0;
} |
29f731d2-2b64-4fbb-b0e2-9a63f2ceae61 | public Heavy() {
} |
54d23548-ba32-45f2-9ffb-c5ae0fcbbd4c | @Override
public int getHealth() {
// TODO Auto-generated method stub
return hp;
} |
0ec5b2f1-4245-4a2b-8e8c-6df7f4dd69c5 | @Override
public int getStrength() {
// TODO Auto-generated method stub
return muscle;
} |
68bb9df5-9d82-4be0-aeb9-d314e4be769a | @Override
public int getDexterity() {
// TODO Auto-generated method stub
return dex;
} |
e54a894c-f0fc-42ad-89fd-308f04fafb76 | @Override
public int getIntelligence() {
// TODO Auto-generated method stub
return intel;
} |
caf9706a-cb44-4ec1-a316-7882d2d1254e | @Override
public int attack() {
// TODO Auto-generated method stub
return 0;
} |
3edf60bb-9d13-427a-ac93-4f13957ee778 | public Wizard() {
} |
fbeb3eac-ad18-4308-bac4-6ea4b9283a85 | @Override
public int getHealth() {
return hp;
} |
d4fd7aa5-d406-4d5b-a02a-f057305e76f4 | @Override
public void setHealth(int health) {
hp = hp + health;
} |
27313c0e-6028-4135-b101-25ff475d0faa | @Override
public int getStrength() {
return muscle;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.