From f3850499b3ce027642da9c06c2956dd42b180f69 Mon Sep 17 00:00:00 2001 From: fdai4616 Date: Thu, 9 Feb 2023 20:18:38 +0100 Subject: [PATCH] refactoring: --- src/main/java/PingPong/Score.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/PingPong/Score.java b/src/main/java/PingPong/Score.java index 4630cff..faa3d60 100644 --- a/src/main/java/PingPong/Score.java +++ b/src/main/java/PingPong/Score.java @@ -19,13 +19,17 @@ public class Score extends Rectangle { ScoreColor(g); g.setFont(new Font("Consolas", Font.BOLD,50)); drawScoreLine(g); - g.drawOval((FRAME_WIDTH/2)-(COURT_CIRCLE/2), (FRAME_HEIGHT/2) - (COURT_CIRCLE/2), COURT_CIRCLE,COURT_CIRCLE); - g.fillOval((FRAME_WIDTH/2)-(CENTER_DOT/2), (FRAME_HEIGHT/2) - (CENTER_DOT/2), CENTER_DOT,CENTER_DOT); + drawScoreOval(g); + g.fillOval((FRAME_WIDTH/2)-(CENTER_DOT/2), (FRAME_HEIGHT/2) - (CENTER_DOT/2), CENTER_DOT,CENTER_DOT); g.drawString(String.valueOf(player_1/10) + String.valueOf(player_1%10), (FRAME_WIDTH/2)- 75, 50); g.drawString(String.valueOf(player_2/10) + String.valueOf(player_2%10), (FRAME_WIDTH/2)+ 20, 50); } + private void drawScoreOval(Graphics g) { + g.drawOval((FRAME_WIDTH/2)-(COURT_CIRCLE/2), (FRAME_HEIGHT/2) - (COURT_CIRCLE/2), COURT_CIRCLE,COURT_CIRCLE); + } + private static void drawScoreLine(Graphics g) { g.drawLine(FRAME_WIDTH/2, 0, FRAME_WIDTH/2, FRAME_HEIGHT); }