forum

Home / DeveloperSection / Forums / How to call a void method from another class

How to call a void method from another class

Anonymous User203105-Nov-2014
I would like to call the public void display() from another class but i don't know how please help me this my program:

publicclassSignalMap
{
    private boolean[][] signal;
    privatedouble threshold;
    private Network net;
    privateint size;
 
    public SignalMap(Network net, double threshold, int size)
    {
        this.net = net;
        this.threshold = threshold;
        signal = new boolean[size][size];
 
        for(int i = 0; i < size; i++)
            {          
                for(int j = 0; j < size; j++)
                {
                    if(net.getSignal(i, j) >= threshold)
                    {
                        signal[i][j] = false;
                    }
                    else
                    {
                        signal[i][j] = true;
                    }
                }
            }
    }
 
    publicvoid display()
    {
        for(int i = 0; i < size; i++)
            {          
                for(int j = 0; j < size; j++)
                {
                    if (signal[i][j].equals(true))
                    {
                        System.out.printf("%5d ", signal[i][j]);
                    }
 
                }
                System.out.println();
            }  
    }
    publicdouble poorSignal()
    {
        int x = 0;
        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                if (signal[i][j] == true)
                {
                    x = x + 1;
                }
            }
        }
        return 1 / (size / x);
    }
}


Please help tell me if I am doing something wrong. This is the question i have to answer : Write a method display in the SignalMap class which prints the array showing those areas which have poor signal (for example, display an X if the signal is poor).


Updated on 05-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By