package bear; import animals.Animal; import bear.components.Body; import…
- User
package bear;
import animals.Animal; import bear.components.Body; import bear.components.Eye;
import java.awt.*;
public class Bear extends Animal {
private Color backgroundColor; private Body body; private Eye leftEye; private Eye rightEye; public Bear(int x, int y, int width, int height, Color primaryColor, Color secondaryColor, Color backgroundColor, boolean lookAtMe) { super(x, y, width, height, primaryColor, secondaryColor); super.lookAt = lookAtMe; method(backgroundColor); } public Bear(int x, int y, int width, int height, Color primaryColor, Color secondaryColor, Color backgroundColor) { super(x, y, width, height, primaryColor, secondaryColor); method(backgroundColor); } private void method(Color backgroundColor) { this.backgroundColor = backgroundColor; // Создаем тело медведя this.body = new Body(x, y, width, height, primaryColor, secondaryColor, backgroundColor); int eyeWidth = width * 40 / 350; int eyeHeight = height * 40 / 550; // Позиции и размеры глаз, согласно вашим расчетам int leftEyeX = x + width * 100 / 350; int leftEyeY = y + height * 130 / 550; this.leftEye = new Eye(leftEyeX, leftEyeY, eyeWidth, eyeHeight); int rightEyeX = x + width * 210 / 350; int rightEyeY = y + height * 130 / 550; this.rightEye = new Eye(rightEyeX, rightEyeY, eyeWidth, eyeHeight); } @Override public void lookAt(int targetX, int targetY) { // Медведь смотрит на заданную точку leftEye.lookAt(targetX, targetY); rightEye.lookAt(targetX, targetY); } @Override public void draw(Graphics2D g) { // Рисуем тело и глаза медведя body.draw(g); leftEye.draw(g); rightEye.draw(g); } @Override public void setPosition(int x, int y) { return; } @Override public boolean getLookAt() { return lookAt; } @Override public boolean getMove() { return move; } @Override public int getXCenter() { return 0; } @Override public int getYCenter() { return 0; }}package bear.components;
import bear.Drawable;
import java.awt.*; import java.awt.geom.GeneralPath;
public class Body implements Drawable { private int x; private int y; private int width; private int height; private Color firstColor; private Color secondColor; private Color background;
public Body(int x, int y, int width, int height, Color primaryColor, Color secondaryColor, Color backgroundColor) { this.x = x; this.y = y; this.width = width; this.height = height; this.firstColor = primaryColor; this.secondColor = secondaryColor; this.background = backgroundColor; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void setWidth(int width) { this.width = width; } public void setHeight(int height) { this.height = height; } public void setColor(Color color) { this.firstColor = color; } // Рисуем фигуру public void draw(final Graphics gr) { } @Override public void draw(Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // тело. Разбито на 2 овала - голова и тушука в дальнейшеим соединяем все вместе с помощью простых линий int xOval1 = (int) (this.x + width * 0.1); int yOval1 = (int) (this.y + height / 55); int widthOval1 = width * 280 / 350; int heightOval1 = (int) height * 285 / 500; int xOval2 = (int) (this.x); int yOval2 = (int) (this.y + height * 280 / 550); int widthOval2 = width; int heightOval2 = (int) height * 270 / 550; GeneralPath bodyPath = new GeneralPath(); bodyPath.moveTo(xOval1, yOval1 + heightOval1 / 2); bodyPath.lineTo(xOval1 + widthOval1, yOval1 + heightOval1 / 2); bodyPath.lineTo(xOval2 + widthOval2, yOval2 + heightOval2 / 2); bodyPath.lineTo(xOval2 + (float) widthOval2 / 2, yOval2 + heightOval2); bodyPath.lineTo(xOval2 + (float) widthOval2 / 2, yOval2 + heightOval2); bodyPath.lineTo(xOval2, yOval2 + (float) heightOval2 / 2); bodyPath.closePath(); BasicStroke bs = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); //уши g.setColor(this.firstColor); g.fillOval(this.x + width * 250 / 350, this.y + height * 20 / 550, width * 30 / 350, height * 50 / 550); g.fillOval(this.x + width * 70 / 350, this.y + height * 15 / 550, width * 30 / 350, height * 50 / 550); g.setColor(Color.black); g.drawOval(this.x + width * 250 / 350, this.y + height * 20 / 550, width * 30 / 350, height * 50 / 550); g.drawOval(this.x + width * 70 / 350, this.y + height * 15 / 550, width * 30 / 350, height * 50 / 550); // прорисовка овалов g.setColor(this.firstColor); g.fill(bodyPath); g.fillOval(xOval2, yOval2, widthOval2, heightOval2); g.fillOval(xOval1, yOval1, widthOval1, heightOval1); g.setColor(Color.BLACK); //нос g.fillOval(this.x + width * 145 / 350, yOval1 + heightOval1 / 2, width * 60 / 350, height * 25 / 550); // глаза (белки, зрачки будут в др. классе) g.setColor(Color.WHITE); g.fillOval(this.x + width * 100 / 350, this.y + height * 130 / 550, width * 40 / 350, height * 40 / 550); g.fillOval(this.x + width * 210 / 350, this.y + height * 130 / 550, width * 40 / 350, height * 40 / 550); // контуры овалов, с учетом, что нам надо только полукруги.. g.setStroke(bs); g.setColor(Color.BLACK); g.drawOval(this.x + width * 100 / 350, this.y + height * 130 / 550, width * 40 / 350, height * 40 / 550); g.drawOval(this.x + width * 210 / 350, this.y + height * 130 / 550, width * 40 / 350, height * 40 / 550); /* g.fillOval(this.x + width * 110 / 350, this.y + height * 140 / 550, width * 20 / 350, height * 20 / 550); g.fillOval(this.x + width * 220 / 350, this.y + height * 140 / 550, width * 20 / 350, height * 20 / 550); - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.