Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Box.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MossyMossy




PostPosted: Tue Nov 03, 2009 8:25 am   Post subject: Box.

What im trying to do, is outline the text with a box, so. The menu here, what is needed is, an outline of * around, so its like a box, i cannot use the draw.box just yet,

(outlining this part with a box of "*")
put "1 - APPLES $1.99"
put "2 - BANANAS $2.99"
put "3 - YUCCA $0.67"
put "4 - CANDY $4.99"
put "5 - CHECK OUT"

Turing:


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Records - Used for Organizing data and such %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type PAYMENT :                                %
    record                                    %
        PRICE : real                          %
        GST : real                            %
        PST : real                            %
    end record                                %
var Customer : PAYMENT                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

var Character : string (1)
Customer.PRICE := 0.00

put "1 - APPLES     $1.99"
put "2 - BANANAS    $2.99"
put "3 - YUCCA      $0.67"
put "4 - CANDY      $4.99"
put "5 - CHECK OUT"

loop
    locate (1, 30)
    put "Total: $", Customer.PRICE
    if hasch then
        getch (Character)
        if Character = "1" then
            Customer.PRICE += 1.99
        elsif Character = "2" then
            Customer.PRICE += 2.99
        elsif Character = "3" then
            Customer.PRICE += 0.67
        elsif Character = "4" then
            Customer.PRICE += 4.99
        elsif Character = "5" then
            Customer.PRICE += 0.97
        elsif Character = "6" then
            exit
        else
            put "Sorry, We do not carry that item!"
        end if
          % delay (2000) % Not really but just incase!
    else
   
    end if
end loop
cls

Customer.GST := ((Customer.PRICE * 5 / 100) * 100 div 1 / 100)
Customer.PST := ((Customer.PRICE * 7 / 100) * 100 div 1 / 100)           

put "GST    :$", Customer.GST
put "PST    :$", Customer.PST
put "Total  :$", Customer.PRICE + Customer.PST + Customer.GST




Turing:


using this method.

var depth, width : int                                                        %
put "Enter the width of the box (less than 60)"                               %
get width                                                                     %
put "Enter the depth of the box (less than 20)"                               %
get depth                                                                     %
cls                                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Arranges to center in window.                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const topRow := (25 - depth) div 2                                            %
const leftColumn := (80 - width) div 2                                        %
var colorNo : int                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draws the top of box.                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
locate (topRow, leftColumn)                                                   %
for count : 1 .. width                                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chooses  the random colours.                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    randint (colorNo, 0, 15)                                                  %
% Set the colours                                                             %
    color (colorNo)                                                           %
    put "*" ..                                                                %
end for                                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draws the bottom of box.                                                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
locate (topRow + depth - 1, leftColumn)                                       %
for count : 1 .. width                                                        %
    randint (colorNo, 0, 15)                                                  %
    color (colorNo)                                                           %
    put "*" ..                                                                %
end for                                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draws left side of box.                                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const sideTop := topRow + 1                                                   %
const sideBottom := topRow + depth - 2                                        %
for row : sideTop .. sideBottom                                               %
    randint (colorNo, 0, 15)                                                  %
    color (colorNo)                                                           %
    locate (row, leftColumn)                                                  %
    put "*" ..                                                                %
end for                                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draws the right side of box.                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const rightColumn := leftColumn + width - 1                                   %
for row : sideTop .. sideBottom                                               %
    randint (colorNo, 0, 15)                                                  %
    color (colorNo)                                                           %
    locate (row, rightColumn)                                                 %
    put "*" ..                                                                %
end for                                                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





so it makes a box of "*" around the menu,

I've tried to locate (1, 30) but it does not work correctly. I have to complete this, but im stuck. So is my programming teacher ^,^ but, our next assignment is with the draw.box way.

but first i have to solve this, Please help!! Sad i've tried to do this all day yesterday but I failed.
Sponsor
Sponsor
Sponsor
sponsor
Murphman




PostPosted: Tue Nov 03, 2009 1:35 pm   Post subject: Re: Box.

Ok i took a look at your program and i got the box around the menu, its inside the loop so the stars continue to change color. Im not sure if this is what u wanted done. if it isn't send me a pm.


code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Records - Used for Organizing data and such %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type PAYMENT :                                %
    record                                    %
        PRICE : real                          %
        GST : real                            %
        PST : real                            %
    end record                                %
var Customer : PAYMENT                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

var Character : string (1)
Customer.PRICE := 0.00
locate (2, 3)
color (black)
put "1 - APPLES     $1.99"
locate (3, 3)
put "2 - BANANAS    $2.99"
locate (4, 3)
put "3 - YUCCA      $0.67"
locate (5, 3)
put "4 - CANDY      $4.99"
locate (6, 3)
put "5 - CHECK OUT"
var colorNo : int
loop

% Draws the top of box.
locate (1, 1)
for count : 1 .. 43

     % Chooses  the random colours.
    randint (colorNo, 1, 15)
    % Set the colours
    color (colorNo)
    put "*" ..
end for

locate (7, 1)
for count : 1 .. 43
    randint (colorNo, 1, 15)
    color (colorNo)
    put "*" ..
end for

const sideTop := 1
const sideBottom := 7
for row : sideTop .. sideBottom
    randint (colorNo, 1, 15)
    color (colorNo)
    locate (row, 1)
    put "*" ..
end for


const Top := 1
const Bottom := 7
for row : Top .. Bottom
    randint (colorNo, 1, 15)
    color (colorNo)
    locate (row, 43)
    put "*" ..
end for

    locate (2, 28)
    color (black)
    put "Total: $", Customer.PRICE
    if hasch then
        getch (Character)
        if Character = "1" then
            Customer.PRICE += 1.99
        elsif Character = "2" then
            Customer.PRICE += 2.99
        elsif Character = "3" then
            Customer.PRICE += 0.67
        elsif Character = "4" then
            Customer.PRICE += 4.99
        elsif Character = "5" then
            Customer.PRICE += 0.97
        elsif Character = "6" then
            exit
        else
            locate (6, 3)
            put "Sorry, We do not carry that item!"
        end if
        % delay (2000) % Not really but just incase!
    else

    end if
end loop
cls

Customer.GST := ((Customer.PRICE * 5 / 100) * 100 div 1 / 100)
Customer.PST := ((Customer.PRICE * 7 / 100) * 100 div 1 / 100)

put "GST    :$", Customer.GST
put "PST    :$", Customer.PST
put "Total  :$", Customer.PRICE + Customer.PST + Customer.GST
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: