如何在Mac的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);
    }
}

在Netbeans左上角的projects选项卡中:

  1. 展开项目树。
  2. 展开Source Packages文件夹。
  3. 用java文件展开包。
  4. 将java文件从包下拖到Source Packages文件夹中。
  5. 将弹出标题为Move Class的对话框。在对话框中单击Refactor按钮。

在Windows中应该是相同的过程。我不知道为什么你的教授告诉你一些不同的东西。

相关内容

  • 没有找到相关文章

最新更新