如何将一个类放在netbeans for Mac的默认包中?

时间:2015-10-09 03:53:04

标签: java macos netbeans

我的教师要求我们从我们的代码中获取包并将其作为默认包。唯一的问题是他告诉我们如何通过Windows做到这一点,我有一台MacBook,所以他的方式不起作用。我无法弄清楚如何去做。我已将代码附加到底部,以防有用。

package romannumeralcalculator;

import java.util.*;

public class RomanNumeralCalculator 
{

    public static void main(String[] args) 
    {

        Scanner input = new Scanner(System.in);
        int integer;

        do {
            System.out.print("Please enter an interger from 1 to 5999. Enter a negative number to exit. \n ->");
            integer = input.nextInt();

        } while (integer >= 6000);

        while (integer == 0) {

            System.out.println("");
            break;
        }

        String results = "";
        int ones = integer % 10;
        int tens = (integer / 10) % 10;
        int hundreds = (integer / 100) % 10;
        int thousands = (integer / 1000) % 1000;

        switch (thousands) {
            case 1:
                results += "M";

                break;

            case 2:
                results += "MM";

                break;
            case 3:
                results += "MMM";

                break;

            case 4:
                results += "MMMM";

                break;

            case 5:
                results += "MMMMM";

                break;

            default:
                System.out.println("");
        }

        switch (hundreds) {
            case 1:
                results += "C";

                break;
            case 2:
                results += "CC";

                break;
            case 3:
                results += "CCC";

                break;
            case 4:
                results += "CD";

                break;
            case 5:
                results += "D";

                break;
            case 6:
                results += "DC";

                break;
            case 7:
                results += "DCC";

                break;
            case 8:
                results += "DCCC";

                break;
            case 9:
                results += "CM";

                break;
            default:
                System.out.println("");
        }
        switch (tens) {
            case 1:
                results += "X";

                break;
            case 2:
                results += "XX";

                break;
            case 3:
                results += "XXX";

                break;
            case 4:
                results += "XL";

                break;
            case 5:
                results += "L";

                break;
            case 6:
                results += "LX";

                break;
            case 7:
                results += "LXX";

                break;
            case 8:
                results += "LXXX";

                break;
            case 9:
                results += "XC";

                break;
            default:
                System.out.println("");
        }

        switch (ones) {
            case 1:
                results += "I";

                break;
            case 2:
                results += "II";

                break;
            case 3:
                results += "III";

                break;
            case 4:
                results += "IV";

                break;
            case 5:
                results += "V";

                break;
            case 6:
                results += "VI";

                break;
            case 7:
                results += "VII";

                break;
            case 8:
                results += "VIII";

                break;
            case 9:
                results += "IX";

                break;
            default:
                System.out.println("");
        }

        System.out.println(results);
    }
}

1 个答案:

答案 0 :(得分:1)

在左上角的Netbeans项目标签中:

  1. 展开项目的树。
  2. 展开Source Packages文件夹。
  3. 使用您的java文件扩展包。
  4. 将java文件从包下拖到Source Packages文件夹。
  5. 将弹出一个标题为Move Class的对话框。在该对话框中单击Refactor按钮。
  6. 这应该是Windows中的相同过程。我不确定你的教授为什么告诉你一些不同的东西。