关于#java#中JOption的问题

关于java中JOption的问题,谢谢!

1.

public class Repaid1 {
        //Declare the variables
        private double money, repaid;
        //Create constructor
        public Repaid1(){
        }
        //compute method
        public void compute(){
                repaid = money * 0.03 + money;
        }
        //Getter and setter
        public void setMoney(double money){this.money = money;}
        public double getMoney() {return money;}
        public double getRepaid() {return repaid;}
    }

2.

import org.w3c.dom.events.MutationEvent;
import javax.swing.JOptionPane;

public class RepaidApp1 {
    public static void main(String[] args) {
            //Declare variables
            double money, repaid;

            //Declare and create object
            Repaid myR = new Repaid();

            //input
            repaid = Integer.parseInt(JOptionPane.showInputDialog(null,"Please enter the money u borrowed from your sister"));
            myR.setRepaid(repaid);


            //process
            myR.compute();

            //output
            repaid = myR.getRepaid();
            JOptionPane.showMessageDialog(null,"money: " + money + ", repaid: " + repaid);
        }
    }

1.的最后一行报错,是由于2.的setRepaid和getRepaid错误,看了半天不知道错在哪了QuQ,求解,多谢了!

Repaid1 类中没有setRepaid,加上去
public void setRepaid(double repaid) {
this.repaid = repaid;
}

你的1里都没有repaid的set方法,你在2里的14行怎么去调用他的set方法呢

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^