Wednesday, March 30, 2011

How Much Do Pearl Earrings Sell For

Implementation Patterns (WORKSHOP)

Well enclose lines of code in which I believe are present Iterator design patterns and the Interpreter.

Iterator Pattern

 System.out.println ("Inventory list \\ n"); 
imprimir.list.iterator Iterator iter = () / / traverse the list of names of stored products and print
while (iter.hasNext ())
System.out.println ("Name:" + iter.next ());
imprimir.listid.iterator
Iterator iter = ();
while (itera.hasNext ()) / / through the list of ID's saved and printed
System.out.println ("ID:" + itera.next ());
iterac = imprimir.listcant.iterator
Iterator ();
while (iterac.hasNext ()) / / through the list of quantities of products stored and printed
System.out.println ("Available:" + iterac.next ());
iteration = imprimir.listprice
Iterator. iterator (); / / Down the list of prices for goods stored and printed
while (iteraci.hasNext ())
System.out.println ("Unit Price:" + iteraci.next ());}



Here} iterators touring show data structures to see if there is information stored and then print the information.

------------------------------------------------ --------------------------------------------------
-------------- Interpreter Pattern


 public class Product {public 



String name;
private int ID, Quantity; / / Named attributes to add products
private float price;

List
list = new ArrayList (); / / generate lists of data that we store
List list = new ArrayList (); / / List the inventory
listcant = new ArrayList ();
List listprice = new ArrayList ();
protected void

ingproducto () / / method which accede to enter
products
{Integer ID = new Integer ( 0), / / \u200b\u200bcreate an object to store integer data
Float Price = new Float (0); / / create a data object to store a floating
Scanner
read = new Scanner (System.in);

System.out.println ("Product Data Entry);
System . out.println ("============================="); / / menu of options for discharging a product
System.out.println ("Enter the Name->");
lectura.nextLine Name = () / / save the name
list.add (name) / / add to the list
System.out. println ("Enter Product ID->");
ID = lectura.nextInt () / / save the ID
listid.add (ID) / / add to the list
System.out.println ("Enter the number of products available->");
Quantity = reading . nextInt (); / / save the amount
listcant.add (Quantity) / / add to the list
System.out.println ("Enter the Product Price->");
lectura.nextFloat Price = (); / / keep the price
listprice.add (Price) / / add to the list



}}


Since only found in the java API declaration lists for String data types, create objects that would allow me to save and read data types integer and floating it as a specialized language, as originally stated was not the case.

0 comments:

Post a Comment