test.java

来自「这是一个买卖系统,一个模拟的系统,根据下订单,看订单,买,等功能」· Java 代码 · 共 66 行

JAVA
66
字号
package Clients;

/**
 * Test the database access
 * @author  Michael Alexander Smith
 * @version 2.0
 */

import Catalogue.*;
import DBAccess.*;
import Middle.*;

class Test
{
  private StockRW theStock      = null;

  public static void main( String args[] )
  {
    Test test = new Test();
    test.process();
  }


  public Test()
  {
  }


  public void process()
  {
    String pn = "0100";
    try
    {
      theStock = new StockRW();
      
      if ( !theStock.exists(pn) )
      {
        System.out.println("Creating " + pn );
        theStock.modifyStock( new Product( pn, "swatch", 100.00, 0 ) );
      }
        
      
      Product pr = theStock.getDetails( pn );
      System.out.println("Stock level = " + pr.getQuantity() );
      
      theStock.addStock( pn, 2 );
      System.out.println("Stock level add 2" );
      
      pr = theStock.getDetails( pn );
      System.out.println("Stock level = " + pr.getQuantity() );
    }
    catch ( StockException e )                      // SQL failure
    {                                               //
      System.out.println( "SQL failure" + "\n"  +   //
                          e.getMessage() + "\n" );
    }
    catch ( Exception e )                           // Unexpected failure
    {                                               //
      System.out.println( "Unexpected failure" + "\n"  +   //
                          e.getMessage() + "\n" );
    }
  }
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?