Java编程简介

Java编程简介,java,Java,我被指派创建一个三维形状,并提示用户输入表面积和体积。我的编码有多处错误,但经过研究,我无法解决这些问题。我试图解决问题,但无法解决,因此我已经解决了。有人能帮我解决问题,或者引导我朝正确的方向走吗 代码如下: //Point originOne = new Point(23, 94); //Rectangle rectOne = new Rectangle(originOne, 100, 200); //Rectangle rectTwo = new Rectangle(50,100); //

我被指派创建一个三维形状,并提示用户输入表面积和体积。我的编码有多处错误,但经过研究,我无法解决这些问题。我试图解决问题,但无法解决,因此我已经解决了。有人能帮我解决问题,或者引导我朝正确的方向走吗

代码如下:

//Point originOne = new Point(23, 94);
//Rectangle rectOne = new Rectangle(originOne, 100, 200);
//Rectangle rectTwo = new Rectangle(50,100);
//Point originOne;
//Point originOne = new Point(23, 94);
import javax.swing.JOptionPane;
public static void main(String[] args) {
    int width;
    int height;
    Rectangle(volume,area);
    JOptionpane.showMessageDialog("please input integer");

public static int volume;
    int vol;
    int side;
    vol =side*3;
public static int area;
    int 

JOptionPane.showMessageDialog( null,"information",
, JOptionPane.OK_CANCEL_OPTION);
JOptionPane.showInputDialog("Please input a value");
public static int surfacearea;
}
public class Rectangle {
    public int x = 0;
    public int y = 0;
    //constructor
    public void Point(int a, int b) {
        x = a;
        y = b;
    }

    public int width = 0;
    public int height = 0;
    public int Point ;
    public int origin;

    // four constructors
    public Rectangle() {
        origin = new Point(0, 0);
    }
    public Rectangle(Point p) {
        origin = p;
    }
    public Rectangle(int w, int h) {
        origin = new Point(0, 0);
        width = w;
        height = h;
    }
    public Rectangle(Point p, int w, int h) {
        origin = p;
        width = w;
        height = h;
    }

    // a method for moving the rectangle
    public void move(int x, int y) {
        origin.x = x;
        origin.y = y;
    }

    // a method for computing the area of the rectangle
    public int Area() {
        //return width * height;
    }
}

这应该有点帮助。。它仍然有很多问题。我希望我的评论能对你有所帮助,如果你还需要什么,请随时发表评论

import javax.swing.JOptionPane;
import java.awt.Point;

public class Rectangle {

    public static int area;
    public static int volume;

    public int x = 0;
    public int y = 0;

    public int width = 0;
    public int height = 0;
    public int Point; // Uh?
    public int origin; // this isnt a Point and yet you are creating an instance of Point..
    //constructor

    /**
     * What is even the point of this????
     */
    public void Point(int a, int b) {
        x = a;
        y = b;
    }

        // main needs to go in a class
    public static void main(String[] args) {
        int width;
        int height;
        Rectangle myRectangle = new Rectangle(volume,area); // actually set a variable
        //JOptionpane.showMessageDialog("please input integer"); // research this..
        int vol;
        int side; //side isnt initialized?
        vol = side*3; //this will not work
        //JOptionPane.showMessageDialog( null,"information", JOptionPane.OK_CANCEL_OPTION);
        //JOptionPane.showInputDialog("Please input a value");
    }

    // four constructors
    public Rectangle() {
        origin = new Point(0, 0);
    }

    public Rectangle(Point p) {
        origin = p;
    }

    public Rectangle(int w, int h) {
        //This isnt calling your point method...
        origin = new Point(0, 0);
        width = w;
        height = h;
    }
    public Rectangle(Point p, int w, int h) {
        origin = p;
        width = w;
        height = h;
    }

    // a method for moving the rectangle
    public void move(int x, int y) {
        origin.x = x; // Again, this is declared as an int.
        origin.y = y; // this is declared as a int.
    }

    // a method for computing the area of the rectangle
    public int Area() {
        return width * height;
    }
}

在令牌void的主语法错误上,@expected int-side-语法错误令牌上的语法错误请输入整数,删除此标记//在四个构造函数point point无法解析为类型origin后这些错误的倍数origin的基元类型int在我尝试运行时没有字段x:i get selection不包含主类型您似乎在main中声明字段并将其公开为static。你不能为局部变量设置静态或任何访问修饰符。你的主方法围绕着一堆属于类主体的东西变量声明等。我很困惑你想要什么。对不起,我是新手,尝试学习,因为我丈夫正在学习java。我只是有很多错误,找不到摆脱它们的方法。这有什么意义呢????嘿,双关语?我想它应该是矩形的构造函数。