Нашли или выдавили из себя код, который нельзя назвать нормальным,
на который без улыбки не взглянешь?
Не торопитесь его удалять или рефакторить, — запостите его на
говнокод.ру, посмеёмся вместе!
public class Spot {
private Piece piece;
private int x;
private int y;
public Spot(int x, int y, Piece piece)
{
this.setPiece(piece);
this.setX(x);
this.setY(y);
}
public Piece getPiece() // метод возвращает объект фигуру
{
return this.piece;
}
public void setPiece(Piece p)
{
this.piece = p;
}
public int getX()
{
return this.x;
}
public void setX(int x)
{
this.x = x;
}
public int getY()
{
return this.y;
}
public void setY(int y)
{
this.y = y;
}
}
Дизайн шахматной игры Эти виды вопросов задаются на интервью, чтобы судить о навыке объектно ориентированного дизайна кандидата. Итак, прежде всего, мы должны подумать о классах. https://habr.com/ru/post/660003/
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
@ControllerAdvice
@Order(10000)
public class BinderControllerAdvice {
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
String[] denylist = new String[]{"class.", "Class.", ".class.", ".Class."};
dataBinder.setDisallowedFields(denylist);
}
}
Критическая 0-day уязвимость в Spring Framework, применяемом во многих Java-проектах
Работа эксплоита сводится к отправке запроса с параметрами "class.module.classLoader.resources.cont ext.parent.pipeline.first.*", обработка которых при использовании "WebappClassLoaderBase" приводит к обращению к классу AccessLogValve. Указанный класс позволяет настроить логгер для создания произвольного jsp-файла в корневом окружении Apache Tomcat и записи в этот файл указанного атакующим кода. Созданный файл становится доступным для прямых запросов и может использоваться в качестве web shell. Для атаки на уязвимое приложение в окружении Apache Tomcat достаточно отправить запрос с определёнными параметрами при помощи утилиты curl.
Анскильные питухи хранят дату рождения в timestamp или в абстрактном формате Date.
Например, если вы родились 20.05.1986, то это 1986.05.20T00:00:00
Угадайте как в приложении отображается дата рождения москвича, когда он находится в Рио-де-Жанейро?
public class ExampleW{
public static void main(){
Scanner input = new Scanner(System.in);
System.out.println("Give mark: ");
int mark = input.nextInt();
String Grade;
switch (mark){
case 100:
case 99:
case 98:
case 97:
case 96:
case 95:
case 94:
case 93:
case 92:
case 91:
case 90:{
Grade = "A+";
break;
}case 89:
case 88:
case 87:
case 86:
case 85:
case 84:
case 83:
case 82:
case 81:
case 80: {
Grade = "A";
break;
}case 75:
case 76:
case 77:
case 78:
case 79:{
Grade = "A-";
break;
}case 70:
case 71:
case 72:
case 73:
case 74:{
Grade ="B+";
break;
} case 69:
case 68:
case 67:
case 66:
case 65:{
Grade ="B";
break;
}
case 64:
case 63:
case 62:
case 61:
case 60:{
Grade = "C+";
break;
}case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
case 58:
case 59: {
Grade = "C";
break;
}case 45:
case 46:
case 47:
case 48:
case 49:{
Grade = "D";
break;
}case 40:
case 41:
case 42:
case 43:
case 44:{
Grade = "E";
break;
}case 0:
case 1:
case 2:
case 3:
...
...
}default: {
Grade = "null";
break;
}}
}
import java.util.Scanner;
public class JavaApplication5 {
public static void main(String[] args) {
Scanner sw = new Scanner(System.in);
System.out.print("Введите число: ");
int week = sw.nextInt();
System.out.println("The day is "+day);
}
class Month{
String day;
switch (int week) {
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
// match the value of week
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
case 7:
day = "Sunday";
break;
default:
day = "---";
break;
}
}
}
Нужно чтобы от пользователя запрашивался номер дня недели, а получалось название. Не пойму, что не так. Помогите, пожалуйста, Добрые Люди
Test Results:
AVTest
checkRandomFiles
Log
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
dos
scan: is safe
scan after: is not safe
expected:<f4wpzFoQD is [not ]safe> but was:<f4wpzFoQD is []safe>
Stack Trace
Completed in 476ms
checkSameFilesWithDifferentIntensitySett ings
Log
virus
scan: is safe
scan after: is not safe
expected:<file1 is [not ]safe> but was:<file1 is []safe>
Stack Trace
Completed in 1ms
Completed in 496ms