Мне нужно вызвать метод из моего двоичного класса, чтобы превратить его в таблицу, класс называется ShepNumber
, а метод называется toBinaryString
, и я знаю, что он работает, мне просто нужно найти способ поместить его в этот код для таблицы.
`public class Multiplicationtable
{
public static void main(String[] args) {
int tableSize = 4 ;
printMultiplicationTable(tableSize);
}
public static void printMultiplicationTable(int tableSize) {
// first print the top header row
System.out.format(" ");
for(int i = 1; i<=tableSize;i++ ) {
System.out.format("%4d",i);
}
System.out.println();
System.out.println("------------------------------------------");
for(int i = 1 ;i<=tableSize;i++) {
// print left most column first
System.out.format("%4d |",i);
for(int j=1;j<=tableSize;j++) {
I need something here that will call the class and make the binary in the table.
}
System.out.println();
}
}
}`
Это другой код для двоичного преобразования.
public class ShepNumber
{
// declare varibles
String binary="";
int testingnumber ;
public ShepNumber(int number)
{
// initialise instance variables
testingnumber = number;
}
// the conversion of the number
public String toBinaryString()
{
int modtest;
modtest= testingnumber%2;
binary=modtest+binary;
this.testingnumber=testingnumber/2;
if (testingnumber>0){
toBinaryString();
}
return binary;
}
}
Любая помощь будет отличной.