Home > Back-end >  A generic class problem bosses look
A generic class problem bosses look

Time:10-13

Write a generic class Purchase , created in the generic class set collection, and defines two methods, respectively, are used to add the goods insertGoods () method and used to view the checkGoods () method, the existing one customer "huawei honor 8" joined the shopping cart, shopping car output necessary commodity information (name of commodity, commodity color and commodity prices)

CodePudding user response:

Import the Java. Text. The DateFormat;
Import the Java. Text. SimpleDateFormat;
Import the Java. Util. Date;
Import the Java. Util. HashSet;
Import the Java. Util. Locale;

The class Bank
{
Private [T] insertGoods;
Private V [] checkGoods;
Public Bank (T [] insertGoods, V [] checkGoods)
{
Enclosing insertGoods=insertGoods;
Enclosing checkGoods=checkGoods;
}
HashSet The set=new HashSet (a);
Public void showmonkey ()
{
Set. The add (new String (" huawei honor 8 "));
}
Public void show ()
{
System. The out. Println (" huawei honor 8 "+" black ", "3699");
System. The out. Println (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - ");
System.out.println();
}
Public static void main (String [] args)
{
//the default to the current time
String [] a={" name of commodity ", "commodity color", "commodities"};
String [] b={" "};
Bank & lt; String, String> Bank=new Bank (a, b);
For (int j=0; j{
System. The out. Print (a [j] + "\ t");
}
System.out.println();
Bank showmonkey ();
Bank show ();

}
}

Trouble bosses to see if there are any problems always have a perception problem
  • Related