if you are trying to make it
like C# or Java then don't
use prototype
make it more like this ...
Code:
<script>
function CashRegister() {
this.total = 0;
this.items = new Array();
this.addItem = function addItem(item){
this.items.push(item);
}
}
function Item(name, unityPrice, category) {
this.name = name;
this.unityPrice = unityPrice;
this.category = category;
}
var cola=new Item("cola", 2, "drinks")
var tea=new Item("tea", 4, "drinks")
var myCash = new CashRegister();
myCash.addItem(cola);
myCash.addItem(tea);
// because myCash.items is an array do this ..,
for (var i = 0; i < myCash.items.length; i++) {
document.writeln(myCash.items[i].name);
}
</script>