Q:

Shapes Toolbox getting inputs for length and width and printing them

I have to make a shapes toolbox with a square, rectangle, circle and triangle. basically the user inputs the shape, then the length, witdh height, circumference etc. and the program will output the shape itself plus text saying the length, width area, perimeter etc.  i have the square class down already with some help from you awesome people and now im working on the rectangle class and ran into a problem.  I will post my main method and my rectangle class here, i will also post my square class as a reference because it works perfectly.  whats getting me is the public Rectanglebox(int width).  this worked great for square when there was only one input which was length but i am trying to figure out how to add a second input into the class for width too since this class will also need that parameter.
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.Scanner;
import javax.swing.JFrame;

public class Main {

    static int input;
    static int length;
    static int width;

    public static void main(String[] args) {

        Scanner sc1 = new Scanner(System.in);
        while(true) {
            System.out.print("\n1 for square\n2 for restangle\n3 for triangle\n4 for circle\n5 to exit\n\nWhich shape do you want? ");
            input = sc1.nextInt();
            if(input == (5)) {
                break;
            }
            if(input == (1)) {

                System.out.print("Input the length: ");
                length = sc1.nextInt();
                Square mySquare = new Square(length);

                JFrame frame = new JFrame();

                frame.setSize(300,400);
                frame.setTitle("ShapeViewer");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                frame.add(mySquare);
                frame.setVisible(true);}

            if(input==(2)) {

                System.out.print("Input the length: ");
                length = sc1.nextInt();
                System.out.print("Input the width: ");
                width = sc1.nextInt();
                Rectanglebox myRectangle = new Rectanglebox(length);

                JFrame frame2 = new JFrame();

                frame2.setSize(300,400);
                frame2.setTitle("ShapeViewer");
                frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                frame2.add(myRectangle);
                frame2.setVisible(true);
            }

            }

        }
    }

import java.util.Scanner;
import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Rectangle;

public class Rectanglebox extends JComponent{

    private int length;
    private int width;

    public Rectanglebox(int length) {
        this.length = length;
    }

    public Rectanglebox(int width) {
        this.width = width;
    }

    public double getArea() {
        return length * width;
    }
    public double getPerimeter() {
        return (length * 2) + (width * 2);
    }

    public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D)g;
        Rectangle square = new Rectangle(100,100,length,length);
        g2.draw(square);
        g2.drawString("Area: "+getArea(), 110, 110+length);
        g2.drawString("Perimeter: " + getPerimeter(), 200, 110+length);
        g2.drawString("Square", 110, 20);
        g2.drawString("Length: " +length, 10, 200+length);
        g2.drawString("Width" +width, 60, 200);

        g2.setColor(Color.black);
        g2.fill(square);
    }
}

import java.util.Scanner;
import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Rectangle;

public class Square extends JComponent{

    private int length; 

    public Square(int length) {
        this.length = length;
    }

    public double getArea() {   
    return length * length;
    }
    public int getPerimeter() {
        return length * 4;
    }
    public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D)g;
        Rectangle square = new Rectangle(50,50,length,length);
        g2.draw(square);
        g2.drawString("Area: "+getArea(), 110, 110+length);
        g2.drawString("Perimeter: " + getPerimeter(), 200, 110+length);
        g2.drawString("Square", 110, 20);
        g2.drawString("Length: " +length, 10, 110+length);
        g2.setColor(Color.black);
        g2.fill(square);
    }
}

I think the main problem here is i dont actually fully understand what this statement is even doing i just know that it works.  I mean i know its a constructor that accepts and sets the length but i dont understand the restrictions for it because i dont see why i cant make another one just like it for width to accept the width input.
public Square(int length) {
        this.length = length;
    }

A:

You cannot use two constructors with the same parameters. You have to create an second constructor for your Rectanglebox, something like:
public Rectanglebox(int length, int width) {
  this.length = length;
  this.width = width;
}

In your Main.java you have to write:
if(input==(2)) {
  System.out.print("Input the length: ");  
  length = sc1.nextInt();
  System.out.print("Input the width: ");
  width = sc1.nextInt();
  Rectanglebox myRectangle = new Rectanglebox(length, width);

