Skip to content

Commit bc6f7b4

Browse files
committed
LP4 M1 - updated starter code and Task 1 instructions
1 parent 5949ab6 commit bc6f7b4

File tree

2 files changed

+84
-56
lines changed

2 files changed

+84
-56
lines changed

DownloadableCodeProjects/LP4_manage-app-data/Data_M1/Starter/Program.cs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ class Program
66
static void Main()
77
{
88
// TASK 1: Create and Manipulate Date and Time Values
9-
// This task will display the output for various DateTime operations.
10-
119
// TASK 1: Step 1 - Get the current date and time, and extract date and time components
12-
// Placeholder for getting the current date and time, and extracting date and time components
10+
1311

1412
// TASK 1: Step 2 - Get the current day of the week and the current month and year
15-
// Placeholder for getting the current day of the week, and the current month and year
13+
1614

1715
// TASK 1: Step 3 - Add days to the current date and parse a date string
18-
// Placeholder for adding days to the current date and parsing a date string
16+
1917

2018
// TASK 1: Step 4 - Format a date and get the current timezone offset
21-
// Placeholder for formatting a date and getting the current timezone offset
19+
2220

2321
// TASK 1: Step 5 - Convert the current time to UTC and display it
24-
// Placeholder for converting the current time to UTC and displaying it
22+
2523

2624
// TASK 2: Calculate Date and Time Values for Bank Customer Transactions
2725
// This task will display the output for customer transactions.
@@ -43,34 +41,31 @@ static void Main()
4341
bankAccounts[3] = account4;
4442

4543
// TASK 2: Step 1 - Create a transaction for the current date and time
46-
// Placeholder for creating a transaction for the current date and time
44+
4745

4846
// TASK 2: Step 2 - Create a transaction for yesterday at 1:15PM
49-
// Placeholder for creating a transaction for yesterday at 1:15PM
47+
5048

5149
// TASK 2: Step 3 - Create transactions for the first three days of December 2024
52-
// Placeholder for creating transactions for the first three days of December 2024
50+
5351

5452
// TASK 2: Step 4 - Display the datedTransactions
55-
// Placeholder for displaying the datedTransactions
5653

57-
// TASK 3: Use Date Ranges to Simulate Transactions Programmatically
58-
// This task will display the output for simulated transactions.
5954

55+
// TASK 3: Use Date Ranges to Simulate Transactions Programmatically
6056
// TASK 3: Step 1 - Define a date range starting on December 12, 2024, and ending on February 20, 2025
61-
// Placeholder for defining a date range
57+
6258

6359
// TASK 3: Step 2 - Generate transactions for the specified date range using the SimulateTransactions class
64-
// Placeholder for generating transactions for the specified date range
60+
6561

6662
// TASK 3: Step 3 - Display the simulated transactions
67-
// Placeholder for displaying the simulated transactions
63+
6864

6965
// TASK 3: Step 4 - Display the number of transactions processed
70-
// Placeholder for displaying the number of transactions processed
7166

72-
// Demonstrate inheritance-based polymorphism
73-
Console.WriteLine("\nDemonstrating inheritance-based polymorphism:");
67+
68+
Console.WriteLine("\nDemonstrating date and time operations:");
7469
foreach (BankAccount account in bankAccounts)
7570
{
7671
Console.WriteLine(account.DisplayAccountInfo());

Instructions/Labs/l2p2-lp4-m1-exercise-impliment-basic-date-time.md

Lines changed: 70 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ Use the following steps to complete this section of the exercise:
6363

6464
1. In the EXPLORER view, collapse the **STARTER** folder, select **SOLUTION EXPLORER**, and expand the **Data_M1** project.
6565

66-
You should see the following code file:
66+
You should see the following project structure:
6767

68+
- Interfaces (folder)
69+
- Models (folder)
70+
- Services (folder)
6871
- Program.cs
6972

7073
1. Take a few minutes to open and review the Program.cs file.
@@ -73,6 +76,16 @@ Use the following steps to complete this section of the exercise:
7376

7477
1. Run the app and review the output in the terminal window.
7578

79+
You should see output that's similar to the following sample:
80+
81+
```plaintext
82+
Demonstrating date and time operations:
83+
Account Number: 19425507, Type: Checking, Balance: 10000, Interest Rate: 0, Customer ID: 0012555399
84+
Account Number: 19425508, Type: Checking, Balance: 500, Interest Rate: 0, Customer ID: 0012555399, Overdraft Limit: 400
85+
Account Number: 19425509, Type: Savings, Balance: 1000, Interest Rate: 0.02, Customer ID: 0012555399, Withdrawal Limit: 6, Withdrawals This Month: 0
86+
Account Number: 19425510, Type: Money Market, Balance: 2000, Interest Rate: 0.04, Customer ID: 0012555399, Minimum Balance: 1000, Interest Rate: 4%, Minimum Opening Balance: 2000
87+
```
88+
7689
To run your app, right-click the **Data_M1** project in the Solution Explorer, select **Debug**, and then select **Start New Instance**.
7790
7891
> **TIP**: If you encounter any issues while completing this exercise, review the provided code snippets and compare them to your own code. Pay close attention to the syntax and structure of the code. If you're still having trouble, you can review the solution code in the sample apps that you downloaded at the beginning of this exercise. To view the Data_M1 solution, navigate to the LP4SampleApps/Data_M1/Solution folder and open the Solution project in Visual Studio Code.
@@ -81,108 +94,128 @@ Use the following steps to complete this section of the exercise:
8194
8295
In this task, you will use the `DateTime`, `DateOnly`, `TimeOnly`, and `TimeZoneInfo` classes to create and manipulate date and time values.
8396
84-
### Task 1 Steps
97+
1. Ensure that you have the Program.cs file open in Visual Studio Code.
98+
99+
1. Locate the following code comment:
100+
101+
```csharp
102+
// TASK 1: Step 1 - Get the current date and time, and extract date and time components
103+
```
85104
86-
1. **Get the current date and time**
87-
Add the following code to retrieve and display the current date and time:
105+
1. To get and display the current date and time, add the following code below the comment:
88106
89107
```csharp
90108
DateTime currentDateTime = DateTime.Now;
91109
Console.WriteLine($"Current Date and Time: {currentDateTime}");
92110
```
93111

94-
1. **Get the current date only**
95-
Add the following code to retrieve and display the current date:
112+
1. Locate the following code comment:
113+
114+
```csharp
115+
// TASK 1: Step 2 - Get the current day of the week and the current month and year
116+
```
117+
118+
1. To get and display the date only, add the following code below the comment:
96119

97120
```csharp
98121
DateOnly currentDate = DateOnly.FromDateTime(DateTime.Now);
99122
Console.WriteLine($"Current Date: {currentDate}");
100123
```
101124

102-
1. **Get the current time only**
103-
Add the following code to retrieve and display the current time:
125+
1. To get and display the current time only, add the following code:
104126

105127
```csharp
106128
TimeOnly currentTime = TimeOnly.FromDateTime(DateTime.Now);
107129
Console.WriteLine($"Current Time: {currentTime}");
108130
```
109131

110-
1. **Get the current day of the week**
111-
Add the following code to retrieve and display the current day of the week:
132+
1. To get and display the current day of the week, add the following code:
112133

113134
```csharp
114135
DayOfWeek currentDayOfWeek = DateTime.Now.DayOfWeek;
115136
Console.WriteLine($"Current Day of the Week: {currentDayOfWeek}");
116137
```
117138

118-
1. **Get the current month and year**
119-
Add the following code to retrieve and display the current month and year:
139+
1. To get and display the current month and year, add the following code:
120140

121141
```csharp
122142
int currentMonth = DateTime.Now.Month;
123143
int currentYear = DateTime.Now.Year;
124144
Console.WriteLine($"Current Month: {currentMonth}, Current Year: {currentYear}");
125145
```
126146

127-
1. **Add days to the current date**
128-
Add the following code to add 10 days to the current date and display the result:
147+
1. Locate the following code comment:
148+
149+
```csharp
150+
// TASK 1: Step 3 - Add days to the current date and parse a date string
151+
```
152+
153+
1. To add 10 days to the current date and display the result, add the following code below the comment:
129154

130155
```csharp
131156
DateTime datePlusDays = DateTime.Now.AddDays(10);
132157
Console.WriteLine($"Date Plus 10 Days: {datePlusDays}");
133158
```
134159

135-
1. **Parse a date string**
136-
Add the following code to parse a date string and display the result:
160+
1. To parse a date string and display the result, add the following code:
137161

138162
```csharp
139163
DateTime parsedDate = DateTime.Parse("2025-03-13");
140164
Console.WriteLine($"Parsed Date: {parsedDate}");
141165
```
142166

143-
1. **Format a date using `.ToString()` method and "yyyy-MM-dd" format**
144-
Add the following code to format the current date and display it:
167+
1. Locate the following code comment:
168+
169+
```csharp
170+
// TASK 1: Step 4 - Format a date and get the current timezone offset
171+
```
172+
173+
1. To format a date using the `.ToString()` method and "yyyy-MM-dd" format, add the following code below the comment:
145174

146175
```csharp
147176
string formattedDate = DateTime.Now.ToString("yyyy-MM-dd");
148177
Console.WriteLine($"Formatted Date: {formattedDate}");
149178
```
150179

151-
1. **Get the current timezone and offset from UTC**
152-
Add the following code to retrieve and display the current timezone and UTC offset:
180+
1. To get the current timezone and offset from UTC, add the following code:
153181

154182
```csharp
155183
TimeZoneInfo currentTimeZone = TimeZoneInfo.Local;
156184
TimeSpan offsetFromUtc = currentTimeZone.GetUtcOffset(DateTime.Now);
157185
Console.WriteLine($"Current Time Zone: {currentTimeZone.DisplayName}, Offset from UTC: {offsetFromUtc}");
158186
```
159187

160-
1. **Convert the current time to UTC**
161-
Add the following code to convert the current time to UTC and display it:
188+
1. Locate the following code comment:
189+
190+
```csharp
191+
// TASK 1: Step 5 - Convert the current time to UTC and display it
192+
```
193+
194+
1. To convert the current time to UTC and display it, add the following code below the comment:
162195

163196
```csharp
164197
DateTime utcTime = DateTime.UtcNow;
165198
Console.WriteLine($"UTC Time: {utcTime}");
166199
```
167200

168-
### Check Task 1 work
201+
1. Save the Program.cs file.
169202

170-
After completing this task, save your work and run debug with **F5**, your app should produce output similar to the following:
203+
1. Run your app and review the output.
171204

172-
```plaintext
173-
Current Date and Time: 3/14/2025 10:00:00 AM
174-
Current Date: 3/14/2025
175-
Current Time: 10:00 AM
176-
Current Day of the Week: Friday
177-
Current Month: 3, Current Year: 2025
178-
Date Plus 10 Days: 3/24/2025 10:00:00 AM
179-
Parsed Date: 3/13/2025 12:00:00 AM
180-
Formatted Date: 2025-03-14
181-
Current Time Zone: Pacific Standard Time, Offset from UTC: -08:00:00
182-
UTC Time: 3/14/2025 6:00:00 PM
183-
```
205+
You should see output similar to the following:
184206

185-
---
207+
```plaintext
208+
Current Date and Time: 3/14/2025 10:00:00 AM
209+
Current Date: 3/14/2025
210+
Current Time: 10:00 AM
211+
Current Day of the Week: Friday
212+
Current Month: 3, Current Year: 2025
213+
Date Plus 10 Days: 3/24/2025 10:00:00 AM
214+
Parsed Date: 3/13/2025 12:00:00 AM
215+
Formatted Date: 2025-03-14
216+
Current Time Zone: Pacific Standard Time, Offset from UTC: -08:00:00
217+
UTC Time: 3/14/2025 6:00:00 PM
218+
```
186219
187220
## Task 2: Calculate Date and Time Values for Bank Customer Transactions
188221

0 commit comments

Comments
 (0)