# Musterlösungen für Aufgabe T1-1.3
#
# fnh, 2004.10.21


# Binärzahl 0b0101,100101 nach Dezimal umrechnen
#
def check_1_3a( inputString, dialog=1 ):
  cl     = Class.forName( 'de.mmkh.tams.NumberParser' )
  parser = cl.newInstance()

  parser.setExpectedFormat( parser.FRACTION ) 
  parser.setExpectedBase( 10 )               
  parser.setExpectedTolerance( 0 )         
  parser.setExpectedValue( 0x5 + 0x25/256 )

  status = parser.check( inputString );      
  if (dialog):
    # from javax.swing import JOptionPane
    JOptionPane.showMessageDialog( None, status )
  return status


# Binärzahl 0b10110,10111 nach Dezimal umrechnen
#
def check_1_3b( inputString, dialog=1 ):
  cl     = Class.forName( 'de.mmkh.tams.NumberParser' )
  parser = cl.newInstance()

  parser.setExpectedFormat( parser.FRACTION )
  parser.setExpectedBase( 10 )               
  parser.setExpectedTolerance( 0 )         
  parser.setExpectedValue( 0x16 + 0x17/256 )

  status = parser.check( inputString ); 
  if (dialog):
    # from javax.swing import JOptionPane
    JOptionPane.showMessageDialog( None, status )
  return status


