2014-12-06 35 views
0

基本上,我試圖在另一個類中調用一個方法,但我遇到了錯誤。訪問另一個類的公共方法

這裏是代碼

public class Ocean 
{ 
    private static int gridWidth, gridHeight; 
    private int safeCount; 
    private boolean shipSafe; 
    private static Ship[] ships; 
    private static int[][] grids; 

public Ocean(int a, int b, int c) 
{ 
    grids = new int[a][b]; 
    ships = new Ship[c]; 
    for(int i = 0; i < c; i++) 
    { 
     ships[i] = Ship(); 
    } 
    gridWidth = a; 
    gridHeight = b; 
} 

我無法訪問公共船級,並出現在ships[i] = Ship();
我試圖重新定義它的錯誤,添加一個構造函數。

+0

請格式化代碼,並添加一個語言標籤(也許是Java?) – Thilo 2014-12-06 02:57:12

回答

0

更改線船[i] = new Ship();

+0

...我意外刪除了它。沒關係。抱歉。 – user59768 2014-12-06 03:25:28

相關問題