import java.awt.*;import javax.swing.*;import java.util.*; // Model classclass FrogModel {    private int xc;    private int yc;     public FrogModel() {        // Initialize frog's coordinates randomly        Random rng = new Random(); // Creating an instance of Random        xc = rng.nextInt(200);        yc = rng.nextInt(200);    }     public int getX() {        return xc;    }     public int getY() {        return yc;    }     public void leap() {        // Update frog's coordinates randomly        Random rng = new Random(); // Creating an instance of Random        xc = rng.nextInt(200);        yc = rng.nextInt(200);    }} // View classclass FrogView extends JPanel {    private FrogModel model;     public FrogView(FrogModel model) {        this.model = model;        setBackground(Color.BLUE);    }     @Override    protected void paintComponent(Graphics gc) {        super.paintComponent(gc);        gc.setColor(Color.GREEN);        gc.fillOval(model.getX(), model.getY(), 10, 10); // Adjust size as needed    }} // Controller classclass FrogController {    private FrogModel model;    private FrogView view;     public FrogController(FrogModel model, FrogView view) {        this.model = model;        this.view = view;    }     public void leap() {        model.leap();        view.repaint();    }} // Main classpublic class FroggerMVC {    public static void main(String[] args) {        FrogModel model = new FrogModel();        FrogView view = new FrogView(model);        FrogController controller = new FrogController(model, view);         // Set up GUI        JFrame frame = new JFrame("Frogger");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.getContentPane().add(view);        frame.pack();        frame.setLocationRelativeTo(null);        frame.setVisible(true);         // Leap button setup        JButton leapButton = new JButton("Leap");        leapButton.addActionListener(e -> controller.leap());        frame.getContentPane().add(leapButton, BorderLayout.SOUTH);    }} i'm trying to run the code in replit but the code is not running. can you check from your side if this code correct and what i do to run this code.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

import java.awt.*;
import javax.swing.*;
import java.util.*;

// Model class
class FrogModel {
    private int xc;
    private int yc;

    public FrogModel() {
        // Initialize frog's coordinates randomly
        Random rng = new Random(); // Creating an instance of Random
        xc = rng.nextInt(200);
        yc = rng.nextInt(200);
    }

    public int getX() {
        return xc;
    }

    public int getY() {
        return yc;
    }

    public void leap() {
        // Update frog's coordinates randomly
        Random rng = new Random(); // Creating an instance of Random
        xc = rng.nextInt(200);
        yc = rng.nextInt(200);
    }
}

// View class
class FrogView extends JPanel {
    private FrogModel model;

    public FrogView(FrogModel model) {
        this.model = model;
        setBackground(Color.BLUE);
    }

    @Override
    protected void paintComponent(Graphics gc) {
        super.paintComponent(gc);
        gc.setColor(Color.GREEN);
        gc.fillOval(model.getX(), model.getY(), 10, 10); // Adjust size as needed
    }
}

// Controller class
class FrogController {
    private FrogModel model;
    private FrogView view;

    public FrogController(FrogModel model, FrogView view) {
        this.model = model;
        this.view = view;
    }

    public void leap() {
        model.leap();
        view.repaint();
    }
}

// Main class
public class FroggerMVC {
    public static void main(String[] args) {
        FrogModel model = new FrogModel();
        FrogView view = new FrogView(model);
        FrogController controller = new FrogController(model, view);

        // Set up GUI
        JFrame frame = new JFrame("Frogger");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(view);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        // Leap button setup
        JButton leapButton = new JButton("Leap");
        leapButton.addActionListener(e -> controller.leap());
        frame.getContentPane().add(leapButton, BorderLayout.SOUTH);
    }
}

i'm trying to run the code in replit but the code is not running. can you check from your side if this code correct and what i do to run this code. 

Expert Solution
steps

Step by step

Solved in 1 steps

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education