comp.lang.ada
 help / color / mirror / Atom feed
* About a design for a supermarket POS (Point of Sale System)
@ 2001-03-02 17:18 MYC
  2001-03-02 19:02 ` Marin David Condic
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: MYC @ 2001-03-02 17:18 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3126 bytes --]

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
============================================================================
===









^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: About a design for a supermarket POS (Point of Sale System)
  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
  2001-03-03  3:40 ` Gerhard Häring
  2 siblings, 0 replies; 4+ messages in thread
From: Marin David Condic @ 2001-03-02 19:02 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4276 bytes --]

This clearly looks like a homework problem. Generally, we're willing to help
with homework assignments if you have a) made an honest effort to find the
answer through traditional means and b) have a *SPECIFIC* question in mind.

Seeing as how you have at least attempted a solution, it doesn't look like
you are asking us to do your homework for you. However, your question is
pretty broad and vague. Is there some particular part of this that has you
confused?

Also, for some reason your code has no indentation. This makes it terribly
hard to look at. Try to get it to the newsgroup as plain ASCII with spaces
instead of tabs & maybe it will appear correctly.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/




"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
>
============================================================================
> ===
>
>
>
>
>
>





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: About a design for a supermarket POS (Point of Sale System)
  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
  2001-03-03  3:40 ` Gerhard Häring
  2 siblings, 0 replies; 4+ messages in thread
From: Ken Garlington @ 2001-03-02 19:26 UTC (permalink / raw)


[-- 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
:
============================================================================
: ===
:
:
:
:
:
:





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: About a design for a supermarket POS (Point of Sale System)
  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
@ 2001-03-03  3:40 ` Gerhard Häring
  2 siblings, 0 replies; 4+ messages in thread
From: Gerhard Häring @ 2001-03-03  3:40 UTC (permalink / raw)


MYC wrote:
> 
> 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.

I have looked at it and the design looks quite good. This is Ada pseudo
code, right?

The only thing I would probably change is to define your own type for
the bar code instead of INTEGER.

An Ada 95 compiler will spot some errors in type declarations, but the
design looks good.

Gerhard

[lengthy pseudo-code not reproduced]
-- 
Sorry for the fake email, please use the real one below to reply.
contact: g e r h a r d @ b i g f o o t . d e
web:     http://highqualdev.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-03-03  3:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2001-03-03  3:40 ` Gerhard Häring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox