[Year 12 SofDev] U4O1 - Coding help

PIKE Philip pikep at bmg.vic.edu.au
Wed Jul 17 13:46:23 EST 2013


To delete an item from an array, I find the simplest way is as follows.

1.      Search for the item and record the index of that item in the array, say found_index

2.      Overwrite the item at found_index with the last item in the array. IE order(found_index) = order(num_items). Assume num_items is the number of items on the order array

3.      Reduce num_items by 1




[cid:bmglogo73b1ca8]

Philip Pike
Director of ICT

Bacchus Marsh Grammar
T. 03 5366 4893  F. 03 5366 4850
E. pikep at bmg.vic.edu.au  W. http://www.bmg.vic.edu.au
South Maddingley Road | PO Box 214 | Bacchus Marsh Victoria 3340


From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au] On Behalf Of Langham, Peter P
Sent: Wednesday, 17 July 2013 1:00 PM
To: Year 12 Software Development Teachers' Mailing List
Subject: [Year 12 SofDev] U4O1 - Coding help

Good afternoon,

I've been working on the Trentham Spud Inn case study available on edulists, created by Elizabeth Wells, as a guide and as practice material for my teaching for U4O1.

In short, it's a Pizza Restaurant ordering system that requires the following tasks:


-        Allow the waiter/waitress to enter the table's order

-        Allow the waiter/waitress to confirm the order with the diners at the table - removing or adding any requested items.

-        Allow special requests to be appended to the order or to individual dishes.

-        Save all of the collected data into a text file

What is the best way to remove an item from the order?

I've been treating the order as one large string, where the diners may place an order as follows:

String Order = "1 x Spudtastic, 1 x Butternut Pumpkin and fresh figs, 1 x Chicken breast and white truffle oil"

I think I'll use a splitting function to separate the string at each comma so we'd end up with

String Order[0] = 1 x Spudtastic
String Order[1] = 1 x Butternut Pumpkin and fresh figs
String Order[2] = 1 x Chicken breast and white truffle oil

To remove the Butternut Pumpkin and fresh figs order

String Order[1] = String Order[2]
String Order[2] = Null or ""

Is there a better way to do this?

Thanks

Peter Langham
Narre Warren South P12



Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.

________________________________
PRIVATE & CONFIDENTIAL
The content of this e-mail and any attachments may be private and confidential, intended only for use of the individual or entity named. If you are not the intended recipient of this message you must not read, forward, print, copy, disclose, use or store in any way the information this e-mail or any attachment contains.
If you are not the intended recipient, please notify the sender immediately and delete or destroy all copies of this e-mail and any attachments.
Our organisation respects the privacy of individuals. For a copy of our privacy policy please go to our website or contact us.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20130717/d7d3071f/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bmglogo73b1ca8
Type: image/png
Size: 4842 bytes
Desc: bmglogo73b1ca8
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20130717/d7d3071f/bmglogo73b1ca8-0001.png 


More information about the sofdev mailing list