From: "Ken Garlington" <Ken.Garlington@computer.org>
Subject: Re: About a design for a supermarket POS (Point of Sale System)
Date: Fri, 02 Mar 2001 19:26:40 GMT
Date: 2001-03-02T19:26:40+00:00 [thread overview]
Message-ID: <QtSn6.405$2T5.148935797@newssvr16.news.prodigy.com> (raw)
In-Reply-To: 97okk9$ll29@tech.port.ac.uk
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 7434 bytes --]
Well, I ran your code (assuming it was intended to be legal Ada code)
through a tool I have that finds errors in such code. Here's your code with
the errors detected included as comments. (You may want to get a similar
tool for your own use.)
--*****
package POS is
type Product_Type is -- type definition expected
subtype Binary_Code is String (1 .. 8) -- missing ";"
subtype Name is String (1 .. 12) -- missing ";"
subtype Price is Float range 0.00 .. 1000.00 -- missing ";"
subtype Quantity is String range 0 .. 1000 -- missing ";"
type Menu is (Process, Modify, Add, Display1, Display2, Report, Quit)
-- missing ";"
type Product is A record -- missing "new"
Bar-Code : Integer -- missing ","
Description : Name
Value : Price
Restock : Quantity
Kind : Product_Type
end record -- no "record" for this "end record"
Item : Product;
type Products is array (1, .. 1000) of Product -- missing ".."
procedure CreateProducts -- missing ";"
-- Description
-- Initializes the array The_Products
procedure NewProduct -- missing ";"
-- Description
-- procedure to allow user to add a new product to the system
procedure Get ( A_Product : out Product ) -- missing ";"
-- Description
-- procedure to prompt user to input full details of a product
end POS;
procedure Point_Of_Sale_System is
The_Products : Products -- missing ";"
begin
CreateProducts;
loop
DisplayMenu;
Get(Menu_Choice);
exit when Menu_Choice = Quit -- missing ";"
case Menu_Choice is
when Process T Process_Shopping_Baskets -- binary operator expected
when Modify T Modify_Product_Details -- statement expected
when Add T New_Product -- statement expected
when Display1 T Display_Products_By_Barcode_Order -- statement
expected
when Display2 T Display_Products_By_Alphabetic_Name_Order --
statement expected
when Report T Report_Reorder_Level -- statement expected
when others T Put("Unexpected Menu Choice!!") -- statement
expected
end case -- missing ";"
-- "end loop" expected for "loop" at line 5
end Point_Of_Sale_System -- missing ";"
--*****
Fixing these problems left the following:
package POS is
type Product_Type is (Unknown);
subtype Binary_Code is String (1 .. 8);
subtype Name is String (1 .. 12);
subtype Price is Float range 0.00 .. 1000.00;
subtype Quantity is String range 0 .. 1000; -- invalid "String"
type Menu is (Process, Modify, Add, Display1, Display2, Report, Quit);
type Product is record
Bar-Code : Integer; -- invalid "-"
Description : Name;
Value : Price;
Restock : Quantity;
Kind : Product_Type;
end record;
Item : Product;
type Products is array (1 .. 1000) of Product;
procedure CreateProducts;
-- Description
-- Initializes the array The_Products
procedure NewProduct;
-- Description
-- procedure to allow user to add a new product to the system
procedure Get ( A_Product : out Product );
-- Description
-- procedure to prompt user to input full details of a product
end POS;
with POS; use POS;
procedure Point_Of_Sale_System is
The_Products : Products;
begin
CreateProducts;
loop
DisplayMenu; -- undefined
Get(Menu_Choice); -- Menu_Choice undefined
exit when Menu_Choice = Quit; -- Menu_Choice undefined
case Menu_Choice is
when Process =>
Process_Shopping_Baskets; -- undefined
when Modify =>
Modify_Product_Details; -- undefined
when Add =>
New_Product; -- undefined
when Display1 =>
Display_Products_By_Barcode_Order; -- undefined
when Display2 =>
Display_Products_By_Alphabetic_Name_Order; -- undefined
when Report =>
Report_Reorder_Level; -- undefined
when others =>
Put("Unexpected Menu Choice!!"); -- undefined
end case;
end loop;
end Point_Of_Sale_System;
"MYC" <fartmanx@hotmail.com> wrote in message
news:97okk9$ll29@tech.port.ac.uk...
: Dear Sir,
:
: I have some problems about Ada. I am not sure whether it is correct.
Would
: you help me check it? Thank you very much.
:
: ��The exercise is to write a design for the solution of the problem, which
: simulates aspects of a supermarket POS (Point of Sale System), while the
: design should consist of Ada or pseudo code for the main procedure, a
: definition of all user defined types, a definition of the arrays and / or
: records used and for each subprogram proposed in this solution including
the
: name of the subprogram, an English description of what it does and the
data
: passed into and out of the subprogram.
:
: Also, the user enters an 8 digit binary number (the bar code), which is
: converted to a decimal equivalent. This decimal value can be used to
locate
: the data for the product.
:
: Moreover, the program is menu driven requiring the following options:
: Process a shopping basket of goods
: Modify or add new product details
: Run off a product inventory by bar code order
: List product details in alphabetic product name order
: Report on any product below the (user supplied) re-order level��
:
: Example data and program requirements
:
: BINARY CODE PRODUCT PRICE QUANTITY
: 0000 0001 COFFEE 2.75 27
: 0000 0010 BREAD 0.44 120
: 0000 0011 MILK 0.89 47
: 0000 0100 Nil 0.00 0
:
: 1111 1100 LIME PICKLE 1.59 30
: 1111 1101 Nil 0.00 0
: 1111 1110 BASMATI 3.99 67
: 1111 1111 TOM YUM 0.55 32
:
:
============================================================================
: =
: My solution is as follows:
:
: 1. User Defined Data Types
:
: type PRODUCT_TYPE IS
: subtype BINARY_CODE is STRING (1..8)
: subtype NAME is STRING (1..12)
: subtype PRICE is FLOAT range 0.00..1000.00
: subtype QUANTITY is STRING range 0..1000
:
: type MENU IS (PROCESS, MODIFY, ADD, DISPLAY1, DISPLAY2, REPORT, QUIT)
:
:
: 2. Data Structures �C Records and Arrays
:
: Record to represent a product:
:
: type PRODUCT is a record
: BAR-CODE : INTEGER
: DESCRIPTION : NAME
: VALUE : PRICE
: RESTOCK : QUANTITY
: KIND : PRODUCT_TYPE
: end record
: ITEM : PRODUCT;
:
: Array of products:
: type PRODUCTS is array (1,..1000) of PRODUCT
:
: 3. Ada Based Design for Main Procedure
:
: Procedure POINT_OF_SALE_SYSTEM is
: THE_PRODUCTS: PRODUCTS
: begin
: CREATEPRODUCTS;
: loop
: DISPLAYMENU;
: GET(MENU_CHOICE);
: exit when MENU_CHOICE = QUIT
: case MENU_CHOICE is
: when PROCESS T PROCESS_SHOPPING_BASKETS
: when MODIFY T MODIFY_PRODUCT_DETAILS
: when ADD T NEW_PRODUCT
: when DISPLAY1 T DISPLAY_PRODUCTS_BY_BARCODE_ORDER
: when DISPLAY2 T DISPLAY_PRODUCTS_BY_ALPHABETIC_NAME_ORDER
: when REPORT T REPORT_REORDER_LEVEL
: when OTHERS T PUT(��Unexpected menu choice!!��)
: end case
: end POINT_OF_SALE_SYSTEM
:
: 4.Subprograms Required
:
: CREATEPRODUCTS
: Description
: Initializes the array THE_PRODUCTS
:
: NEWPRODUCT
: Description
: Procedure to allow user to add a new product to the system
:
: GET(A_PRODUCT: out PRODUCT)
: Description
: Procedure to prompt user to input full details of a product
:
============================================================================
: ===
:
:
:
:
:
:
next prev parent reply other threads:[~2001-03-02 19:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-02 17:18 About a design for a supermarket POS (Point of Sale System) MYC
2001-03-02 19:02 ` Marin David Condic
2001-03-02 19:26 ` Ken Garlington [this message]
2001-03-03 3:40 ` Gerhard Häring
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox