class PlayerMaker:
def __init__(self):
self.name = ""
self.hp = 0
self.at = 0
...
def setName( self, item ):
self.name = item.text
def setHp( self, item ):
self.hp = int(item.text)
def setAt( self, item ):
self.at = int(item.text)
def setDf( self, item ):
self.df = int(item.text)
def setAg( self, item ):
self.ag = int(item.text)
...
public class ISBNConverter {
public static void main(String[] args) {
...
char [] cisbn = isbn.toCharArray();
int [] iisbn;
iisbn = new int[10];
...
for (int idx=0; idx<9; idx++) {
iisbn[idx] = Character.digit(cisbn[idx], 10);
if ((iisbn[idx]<0)||(iisbn[idx]>9)){
System.out.println("Error: Not a number is included in the 9 numbers.");
System.exit(0);
...
def main(args):
...
cisbn = isbn
iisbn = [None] * 10;
...
for idx in range(9):
if not cisbn[idx].isdigit():
print("Error: Not a number is included in the 9 numbers.")
sys.exit(0)
iisbn[idx] = int(cisbn[idx])
if cisbn[9] == 'X':
iisbn[9] = 10
else:
class PlayerMaker:
def __init__(self):
self.name = ""
self.hp = 0
...
def setName( self, item ):
self.name = item.text
def setHp( self, item ):
self.hp = int(item.text)
...
Like for(i=0; i<9; i++) {...}
for idx in range(9):
For example...
for i in range(9):
if not cisbn[i].isdigit():
...
Initializing array...
iisbn = [None] * 10;
For example...
for idx in range(9):
...
iisbn[idx] = int(cisbn[idx])
そうだ、リファクタリングしよう