Skip to content

Commit b91d07b

Browse files
author
Oyvind Timian Dokk Husveg
committed
Oyvind Husveg
1 parent a0739af commit b91d07b

File tree

1 file changed

+17
-12
lines changed
  • csharp-fundamentals-lists.Main

1 file changed

+17
-12
lines changed

csharp-fundamentals-lists.Main/Core.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Core
1919

2020
public Core()
2121
{
22-
22+
2323
}
2424

2525
public List<string> Question1()
@@ -31,26 +31,31 @@ public List<string> Question1()
3131
// TODO: 1. Find the add method and add two more flavours of ice cream: "Phish Food", "Peanut Butter Cup"
3232

3333
//write code here
34+
_iceCreams.Add("Phish Food");
35+
_iceCreams.Add("Peanut Butter Cup");
36+
37+
3438

35-
return _iceCreams;
39+
return _iceCreams;
3640
}
3741

3842
public int Question2()
3943
{
40-
44+
4145
//TODO: find the lists method that returns the number of ice creams in the list and return this.
4246

43-
// remove exception and write code here
44-
throw new NotImplementedException();
47+
return _iceCreams.Count;
4548
}
4649
public List<string> Question3()
4750
{
4851

4952
// The code below concatenates this.MoreIceCream to the _iceCreams list into a new results list.
50-
//TODO: you can 'chain' methods on the _iceCream list, so add another Concat to include EvenMoreIceCream (this is defined below) to the result list . e.g. _iceCreams.Concat(this.MoreIceCream).Concat(other list to concat).ToList()
53+
// TODO: you can 'chain' methods on the _iceCream list, so add another Concat to
54+
// include EvenMoreIceCream (this is defined below) to the result list . e.g.
55+
// _iceCreams.Concat(this.MoreIceCream).Concat(other list to concat).ToList()
56+
57+
List<string> results = _iceCreams.Concat(this.MoreIceCream).Concat(this.EvenMoreIceCream).ToList();
5158

52-
List<string> results = _iceCreams.Concat(this.MoreIceCream).ToList();
53-
5459
return results;
5560

5661
// remove exception and write code here
@@ -59,14 +64,14 @@ public List<string> Question3()
5964
public List<string> Question4()
6065
{
6166

62-
6367
//TODO: Remove the duplicates using the .Distinct() placing just before the .ToList()
64-
// copy the List declaration line from Question3 and add the .Distinct() into the chain. e.g. _iceCreams.Concat(this.MoreIceCream).Concat(other list to concat).Distinct().ToList()
68+
// copy the List declaration line from Question3 and add the .Distinct() into the chain.
69+
// e.g. _iceCreams.Concat(this.MoreIceCream).Concat(other list to concat).Distinct().ToList()
6570
// be sure to include the MoreIceCream and EvenMoreIceCream lists
6671

6772

68-
List<string> results = _iceCreams;
69-
// remove exception and write code here
73+
List<string> results = _iceCreams.Concat(this.MoreIceCream).Concat(this.EvenMoreIceCream).Distinct().ToList();
74+
7075
return results;
7176
}
7277

0 commit comments

Comments
 (0)