Can anyone tell me what this set of codes mean?
Can anyone tell me what this set of codes mean?
This set of codes was taught in class, but i do not understand what they mean and why we need to use them. For each one of them, please write some comments under 1), 2) and 3) if you can. Help will be appreciated thanks!
1) ArrayList
ArrayList
newProduct [] arrProduct = new newProduct[size];
ShoppingCart(newProduct[] tmp, Scanner in){
arrProduct = tmp;
size = arrProduct.length;
displayMenu(in);
2) switch (in.nextInt()){
case product_inven:
purchaseproduct(in);break;
case product_inventory:
productMenu(in);break;
case shopping_cart:
purchaseproduct(in); break;
case exit_application:
return false;
default:
enterinvalid(); break;
}
clearscreen();
return true;
}
3) public void purchaseproduct(Scanner in){
int size = 0;
newProduct [] tmp = new newProduct[size];
tmp = list.getproarray();
if(tmp.length == 0){
System.out.println(“There are no products in inventory:”);
}
else{
ShoppingCart doshop = new ShoppingCart(tmp, in);
}
}
Best answer:
Who wrote that? The instructor? This is supposed to be Java, right?
There is some messed up crap, such as allocating a 0 size array and immediately discarding it.
1) This are the member variables.
2) This is a switch statement and so one of the “case” items below will execute, depending on the value returned by in.nextInt()
3) This is a method.
Tags: anyone, Codes, mean, tell, this
Under Forum

Leave a Comment for Can anyone tell me what this set of codes mean?
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed