私はプログラミングクラスのゲームに取り組んでおり、Eclipse でコードを書きましたが、目に見えるエラーはありませんが、コンパイルすると次のエラーメッセージが表示されます。
TogizKumalak20.java:220: エラー: クラス board20 のメソッド moveBoard は、指定された型に適用できません。playBoard.moveBoard(playTurn, keyCharAsInt); 必須: cup20 検出: int,int 理由: 実引数リストと仮引数リストの長さが異なります
これの原因と修正方法がわかりません。ご意見をお待ちしております。よろしくお願いします。
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.Cursor;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.*;
import java.io.*;
import javax.swing.JFileChooser;
import java.awt.Color;
import java.awt.event.*;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class TogizKumalak20
{
public static void main(String[] args)
{
TKFrame myFrame = new TKFrame();
myFrame.setTitle("Togiz Kumalak U22");
myFrame.setVisible(true);
}
}
class TKFrame extends JFrame
{
private TKPanel myPanel;
private final int FRAMEW = 700;
private final int FRAMEH = 700;
public TKFrame()
{
setSize(FRAMEW, FRAMEH);
myPanel = new TKPanel();
Container contentPane = getContentPane();
contentPane.add(myPanel);
addWindowListener(new WindowCloser());
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu fileMenu = new JMenu("File");
menuBar.add(fileMenu);
JMenuItem restartItem = new JMenuItem("Restart");
fileMenu.add(restartItem);
RestartListener myRestartListener = new RestartListener();
restartItem.addActionListener(myRestartListener);
JMenuItem exitItem = new JMenuItem("Exit");
fileMenu.add(exitItem);
ExitListener myExitListener = new ExitListener();
exitItem.addActionListener(myExitListener);
}
private class WindowCloser extends WindowAdapter
{
public void windowClosing(WindowEvent event)
{
dispose();
}
}
private class RestartListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
myPanel.renewBoard();
myPanel.renewTextArea();
myPanel.setMoveCount(1);
}
}
private class ExitListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
System.exit(0);
}
}
}
class TKPanel extends JPanel
{
private board20 playBoard;
private int playTurn;
private JTextArea actionRecordArea;
private JScrollPane actionScrollPane;
private int moveCount = 1;
public TKPanel()
{
super();
playTurn = 1;
playBoard = new board20();
actionRecordArea = new JTextArea(6, 24);
actionRecordArea.setEditable(false);
actionScrollPane = new JScrollPane(actionRecordArea,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(actionScrollPane, "North");
addMouseListener(new MouseHandler());
addMouseMotionListener(new MouseMotionHandler());
addKeyListener(new KeyHandler());
setFocusable(true);
}
public void renewBoard()
{
playBoard = new board20();
repaint();
}
public void renewTextArea()
{
actionRecordArea.setText("");
repaint();
}
public int getMoveCount()
{
return moveCount;
}
public void setMoveCount(int countIn)
{
moveCount = countIn;
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
playBoard.drawBoard(g2);
}
private class MouseHandler extends MouseAdapter
{
public void mouseClicked(MouseEvent event)
{
cup20 returnedCup;
returnedCup = playBoard.isTheMouseInaCup(event.getPoint());
if(returnedCup != null)
{
if(returnedCup.getWhoseCup() == playTurn)
{
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
playBoard.moveBoard(returnedCup);
int whatCupNumber = playBoard.getCupNumber(returnedCup);
actionRecordArea.append("Move: " + moveCount + ". Player: " + playTurn + ". Cup: " + whatCupNumber + ".\n");
moveCount++;
if(playTurn == 1)
playTurn = 2;
else
playTurn = 1;
repaint();
}
}
}
}
private class MouseMotionHandler extends MouseMotionAdapter
{
public void mouseMoved(MouseEvent event)
{
cup20 retCup = playBoard.isTheMouseInaCup(event.getPoint());
if(retCup == null)
setCursor(Cursor.getDefaultCursor());
else
{
if(retCup.getWhoseCup() == playTurn)
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
else
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
}
}
}
private class KeyHandler extends KeyAdapter
{
public void keyTyped(KeyEvent event)
{
char keyChar = event.getKeyChar();
int keyCharAsInt;
if(keyChar == '1' || keyChar == '2' || keyChar == '3' || keyChar == '4' || keyChar == '5' || keyChar == '6' || keyChar =='7' || keyChar == '8' || keyChar == '9')
{
keyCharAsInt = (int) keyChar - 48;
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
playBoard.moveBoard(playTurn, keyCharAsInt);
actionRecordArea.append("Move: " + moveCount + ". Player: " + playTurn + ". Cup: " + keyCharAsInt + ".\n");
moveCount++;
if(playTurn == 1)
playTurn = 2;
else
playTurn = 1;
repaint();
}
else
{
}
}
public board20 getBoard()
{
return playBoard;
}
public String getText()
{
return actionRecordArea.getText();
}
public void setText(String textIn)
{
actionRecordArea.setText(textIn);
}
}
}