Skip to content

Commit 7fd6e9d

Browse files
Merge remote-tracking branch 'origin/master' into mr/295-tool-to_create_labs_folder
2 parents cdb8faf + 1261a3a commit 7fd6e9d

File tree

8 files changed

+96
-172
lines changed

8 files changed

+96
-172
lines changed

courses/ada_essentials/010_overview/03-setup.rst

Lines changed: 0 additions & 84 deletions
This file was deleted.

courses/ada_essentials/030_scalar_types/02-discrete_numeric_types_with_mod.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ Modular Type Semantics
153153
- **Bit shifts**
154154
- Values as **bit-sequences**
155155

156-
--------------------------
157-
Predefined Modular Types
158-
--------------------------
156+
--------------------------------
157+
Predefined Sized Numeric Types
158+
--------------------------------
159159

160160
* In :ada:`Interfaces` package
161161

courses/ada_essentials/040_statements/88-statements.lab.rst

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,22 @@ Statements Lab
88

99
* Requirements
1010

11-
- Create a simple algorithm to count number of hours worked in a week
11+
- Create a simple program to build a time tracking sheet for the week
12+
13+
+ For every day of the week, print a line indicating the time of day (in hours)
1214

13-
+ Use `Ada.Text_IO.Get_Line` to ask user for hours worked on each day
14-
+ Any hours over 8 gets counted as 1.5 times number of hours (e.g. 10 hours worked will get counted as 11 hours towards total)
15-
+ Saturday hours get counted at 1.5 times number of hours
16-
+ Sunday hours get counted at 2 times number of hours
15+
- Conditions for printing time
1716

18-
- Print total number of hours "worked"
17+
+ Only print times for "normal" working hours
18+
+ No working on Sunday, so no times printed
19+
+ Saturday is a half-day, so only print every other time slot
1920

2021
* Hints
2122

22-
- Use `for` loop to iterate over days of week
23-
- Use `if` statement to determine overtime hours
24-
- Use `case` statement to determine weekend bonus
25-
26-
-----------------------------
27-
Statements Lab Extra Credit
28-
-----------------------------
29-
30-
* Use an inner loop when getting hours worked to check validity
31-
32-
- Less than 0 should exit outer loop
33-
- More than 24 should not be allowed
23+
- Use a :ada:`for` loop to iterate over days of week and hours
24+
- Use a :ada:`case` statement to determine how start and end time
25+
- Use an :ada:`if` statement to determine if you are printing a time
26+
- For simplicity, feel free to use a 24-hour clock
3427

3528
-------------------------
3629
Statements Lab Solution

courses/ada_essentials/040_statements/lab/statements/ada95/main.adb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ with Ada.Text_IO; use Ada.Text_IO;
22
procedure Main is
33
type Days_Of_Week_T is
44
(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
5+
<<<<<<< HEAD
56
type Hours_Worked is digits 6;
67

78
Total_Worked : Hours_Worked := 0.0;
@@ -36,4 +37,36 @@ begin
3637
end loop Day_Loop;
3738

3839
Put_Line (Hours_Worked'Image (Total_Worked));
40+
=======
41+
type Hours is mod 24;
42+
Start : Hours;
43+
Finish : Hours;
44+
Big_Block : Boolean;
45+
begin
46+
Day_Loop :
47+
for Day in Days_Of_Week_T loop
48+
case Day is
49+
when Sunday =>
50+
Start := 1;
51+
Finish := 0;
52+
when Saturday =>
53+
Start := 9;
54+
Finish := 13;
55+
Big_Block := True;
56+
when Monday .. Friday =>
57+
Start := 9;
58+
Finish := 17;
59+
Big_Block := False;
60+
end case;
61+
Put_Line (Days_Of_Week_T'Image (Day));
62+
Put_Line ("======");
63+
for Hour in Start .. Finish loop
64+
if Big_Block and then (2 * (Hour / 2) = Hour) then
65+
New_Line;
66+
else
67+
Put_Line (" " & Hours'Image (Hour) & "00");
68+
end if;
69+
end loop;
70+
end loop Day_Loop;
71+
>>>>>>> origin/master
3972
end Main;

courses/ada_essentials/040_statements/lab/statements/answer/main.adb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ with Ada.Text_IO; use Ada.Text_IO;
22
procedure Main is
33
type Days_Of_Week_T is
44
(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
5+
<<<<<<< HEAD
56
type Hours_Worked is digits 6;
67

78
Total_Worked : Hours_Worked := 0.0;
@@ -33,4 +34,36 @@ begin
3334
end loop Day_Loop;
3435

3536
Put_Line (Total_Worked'Image);
37+
=======
38+
type Hours is mod 24;
39+
Start : Hours;
40+
Finish : Hours;
41+
Big_Block : Boolean;
42+
begin
43+
Day_Loop :
44+
for Day in Days_Of_Week_T loop
45+
case Day is
46+
when Sunday =>
47+
Start := 1;
48+
Finish := 0;
49+
when Saturday =>
50+
Start := 9;
51+
Finish := 13;
52+
Big_Block := True;
53+
when Monday .. Friday =>
54+
Start := 9;
55+
Finish := 17;
56+
Big_Block := False;
57+
end case;
58+
Put_Line (Day'Image);
59+
Put_Line ("======");
60+
for Hour in Start .. Finish loop
61+
if Big_Block and then (2 * (Hour / 2) = Hour) then
62+
New_Line;
63+
else
64+
Put_Line (" " & Hour'Image & "00");
65+
end if;
66+
end loop;
67+
end loop Day_Loop;
68+
>>>>>>> origin/master
3669
end Main;

courses/ada_essentials/040_statements/lab/statements/prompt/main.adb

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,22 @@ with Ada.Text_IO; use Ada.Text_IO;
22
procedure Main is
33
type Days_Of_Week_T is
44
(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
5-
type Hours_Worked is digits 6;
6-
7-
Total_Worked : Hours_Worked := 0.0;
8-
Hours_Today : Hours_Worked;
9-
Overtime : Hours_Worked;
5+
type Hours is mod 24;
6+
Start : Hours;
7+
Finish : Hours;
108
begin
11-
-- For each day in the Days_Of_Week_T loop
12-
-- Print prompt indicating which day we're asking for
13-
-- Loop "forever"
14-
Hours_Today := Hours_Worked'Value (Get_Line);
15-
-- exit the main loop if hours worked < 0
16-
if Hours_Today > 24.0 then
17-
Put_Line ("I don't believe you");
18-
else
19-
-- exit the input loop if a reasonable number is reached
20-
null;
21-
end if;
22-
-- if hours worked > 8 then
23-
Overtime := Hours_Today - 8.0;
24-
Hours_Today := Hours_Today + 1.5 * Overtime;
25-
-- Calculate actual hours paid for based on day of the week
26-
-- Monday - Friday, just add hours worked
27-
-- Saturday - hours worked * 1.5
28-
-- Sunday - hours worked * 2
9+
-- Loop over Days_Of_Week_T
10+
11+
-- Use a "case" statement to determine when the workday
12+
-- starts and ends based on the day of the week
13+
Start := 0;
14+
Finish := 23;
15+
16+
-- Print a header indicating what day of the week it is
17+
Put_Line ("Day of Week"); -- (example)
18+
-- For Saturday, print a line for every other hour (e.g. 3, 5, 7)
19+
Put_Line (Hours'Image (Start)); -- (example)
20+
-- For other days, print a line for every hour
21+
Put_Line (Hours'Image (Finish)); -- (example)
2922

30-
Put_Line (Hours_Worked'Image (Total_Worked));
3123
end Main;

courses/ada_essentials/labs/prompts/030_scalar_types/default.gpr

Lines changed: 0 additions & 3 deletions
This file was deleted.

courses/ada_essentials/labs/prompts/030_scalar_types/main.adb

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)