Skip to content

Commit e8b62a1

Browse files
author
Eric Camplin
committed
Date Time Starter/Solution + Instructions. Complete
1 parent ada9e46 commit e8b62a1

File tree

2 files changed

+314
-100
lines changed

2 files changed

+314
-100
lines changed

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

Lines changed: 29 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -5,146 +5,75 @@ class Program
55
{
66
static void Main()
77
{
8-
// TASK 1: Create Date and Time Values
8+
// TASK 1: Create and Manipulate Date and Time Values
9+
// This task will display the output for various DateTime operations.
910

10-
// TASK 1: Step 1 - Get the current date and time
11-
// NEW CODE WILL GO HERE
11+
// 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
1213

13-
// TASK 1: Step 2 - Get the current date only
14-
// NEW CODE WILL GO HERE
14+
// 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
1516

16-
// TASK 1: Step 3 - Get the current time only
17-
// NEW CODE WILL GO HERE
17+
// 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
1819

19-
// TASK 1: Step 4 - Get the current day of the week
20-
// NEW CODE WILL GO HERE
20+
// 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
2122

22-
// TASK 1: Step 5 - Get the current month and year
23-
// NEW CODE WILL GO HERE
24-
25-
// TASK 1: Step 6 - Add days to the current date
26-
// NEW CODE WILL GO HERE
27-
28-
// TASK 1: Step 7 - Parse a date string
29-
// NEW CODE WILL GO HERE
30-
31-
// TASK 1: Step 8 - Format a date using .ToString() method and "yyyy-MM-dd" format
32-
// NEW CODE WILL GO HERE
33-
34-
// TASK 1: Step 9 - Get the current timezone and offset from UTC
35-
// NEW CODE WILL GO HERE
36-
37-
// TASK 1: Step 10 - Convert the current time to UTC
38-
// NEW CODE WILL GO HERE
23+
// 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
3925

4026
// TASK 2: Calculate Date and Time Values for Bank Customer Transactions
27+
// This task will display the output for customer transactions.
4128

42-
// Create a new customer and accounts
29+
// New customer and accounts
4330
string firstName = "Tim";
4431
string lastName = "Shao";
45-
BankCustomer customer2 = new BankCustomer(firstName, lastName);
32+
BankCustomer customer1 = new StandardCustomer(firstName, lastName);
4633

47-
BankAccount account1 = new BankAccount(customer2.CustomerId, 10000);
48-
BankAccount account2 = new CheckingAccount(customer2.CustomerId, 500, 400);
49-
BankAccount account3 = new SavingsAccount(customer2.CustomerId, 1000);
50-
BankAccount account4 = new MoneyMarketAccount(customer2.CustomerId, 2000);
34+
BankAccount account1 = new BankAccount(customer1.CustomerId, 10000);
35+
BankAccount account2 = new CheckingAccount(customer1.CustomerId, 500, 400);
36+
BankAccount account3 = new SavingsAccount(customer1.CustomerId, 1000);
37+
BankAccount account4 = new MoneyMarketAccount(customer1.CustomerId, 2000);
5138

5239
BankAccount[] bankAccounts = new BankAccount[4];
53-
5440
bankAccounts[0] = account1;
5541
bankAccounts[1] = account2;
5642
bankAccounts[2] = account3;
5743
bankAccounts[3] = account4;
5844

5945
// TASK 2: Step 1 - Create a transaction for the current date and time
60-
// NEW CODE WILL GO HERE
46+
// Placeholder for creating a transaction for the current date and time
6147

6248
// TASK 2: Step 2 - Create a transaction for yesterday at 1:15PM
63-
// NEW CODE WILL GO HERE
49+
// Placeholder for creating a transaction for yesterday at 1:15PM
6450

6551
// TASK 2: Step 3 - Create transactions for the first three days of December 2024
66-
// NEW CODE WILL GO HERE
52+
// Placeholder for creating transactions for the first three days of December 2024
6753

6854
// TASK 2: Step 4 - Display the datedTransactions
69-
// NEW CODE WILL GO HERE
55+
// Placeholder for displaying the datedTransactions
7056

7157
// TASK 3: Use Date Ranges to Simulate Transactions Programmatically
58+
// This task will display the output for simulated transactions.
7259

7360
// TASK 3: Step 1 - Define a date range starting on December 12, 2024, and ending on February 20, 2025
74-
// NEW CODE WILL GO HERE
61+
// Placeholder for defining a date range
7562

7663
// TASK 3: Step 2 - Generate transactions for the specified date range using the SimulateTransactions class
77-
// NEW CODE WILL GO HERE
64+
// Placeholder for generating transactions for the specified date range
7865

7966
// TASK 3: Step 3 - Display the simulated transactions
80-
// NEW CODE WILL GO HERE
67+
// Placeholder for displaying the simulated transactions
8168

8269
// TASK 3: Step 4 - Display the number of transactions processed
83-
// NEW CODE WILL GO HERE
70+
// Placeholder for displaying the number of transactions processed
8471

8572
// Demonstrate inheritance-based polymorphism
86-
Console.WriteLine("\nDemonstrating inheritance-based polymorphism...");
87-
// Create a new customer and accounts for inheritance-based polymorphism
88-
Console.WriteLine("Creating BankCustomer and BankAccount objects...");
89-
90-
// Create accounts for customer1
91-
Console.WriteLine("Creating BankAccount objects for customer1...");
92-
93-
// Demonstrate polymorphism by accessing overridden methods from the base class reference
94-
Console.WriteLine("\nDemonstrating polymorphism by accessing overridden methods from the base class reference:");
95-
73+
Console.WriteLine("\nDemonstrating inheritance-based polymorphism:");
9674
foreach (BankAccount account in bankAccounts)
9775
{
9876
Console.WriteLine(account.DisplayAccountInfo());
9977
}
100-
101-
foreach (BankAccount account in bankAccounts)
102-
{
103-
if (account is CheckingAccount checkingAccount)
104-
{
105-
// CheckingAccount: Withdraw within overdraft limit
106-
Console.WriteLine("\nCheckingAccount: Attempting to withdraw $600 (within overdraft limit)...");
107-
checkingAccount.Withdraw(600);
108-
Console.WriteLine(checkingAccount.DisplayAccountInfo());
109-
110-
// CheckingAccount: Withdraw exceeding overdraft limit
111-
Console.WriteLine("\nCheckingAccount: Attempting to withdraw $1000 (exceeding overdraft limit)...");
112-
checkingAccount.Withdraw(1000);
113-
Console.WriteLine(checkingAccount.DisplayAccountInfo());
114-
}
115-
else if (account is SavingsAccount savingsAccount)
116-
{
117-
// SavingsAccount: Withdraw within limit
118-
Console.WriteLine("\nSavingsAccount: Attempting to withdraw $200 (within withdrawal limit)...");
119-
savingsAccount.Withdraw(200);
120-
Console.WriteLine(savingsAccount.DisplayAccountInfo());
121-
122-
// SavingsAccount: Withdraw exceeding limit
123-
Console.WriteLine("\nSavingsAccount: Attempting to withdraw $900 (exceeding withdrawal limit)...");
124-
savingsAccount.Withdraw(900);
125-
Console.WriteLine(savingsAccount.DisplayAccountInfo());
126-
127-
// SavingsAccount: Exceeding maximum number of withdrawals per month
128-
Console.WriteLine("\nSavingsAccount: Exceeding maximum number of withdrawals per month...");
129-
for (int i = 0; i < 7; i++)
130-
{
131-
Console.WriteLine($"Attempting to withdraw $50 (withdrawal {i + 1})...");
132-
savingsAccount.Withdraw(50);
133-
Console.WriteLine(savingsAccount.DisplayAccountInfo());
134-
}
135-
}
136-
else if (account is MoneyMarketAccount moneyMarketAccount)
137-
{
138-
// MoneyMarketAccount: Withdraw within minimum balance
139-
Console.WriteLine("\nMoneyMarketAccount: Attempting to withdraw $1000 (maintaining minimum balance)...");
140-
moneyMarketAccount.Withdraw(1000);
141-
Console.WriteLine(moneyMarketAccount.DisplayAccountInfo());
142-
143-
// MoneyMarketAccount: Withdraw exceeding minimum balance
144-
Console.WriteLine("\nMoneyMarketAccount: Attempting to withdraw $1900 (exceeding minimum balance)...");
145-
moneyMarketAccount.Withdraw(1900);
146-
Console.WriteLine(moneyMarketAccount.DisplayAccountInfo());
147-
}
148-
}
14978
}
15079
}

0 commit comments

Comments
 (0)