Clone this repository and bring the code pieces you need into your BDSA Assignments GitHub repository. Done!
Compare the following two methods:
int GreaterCount<T, U>(IEnumerable<T> items, T x)
where T : IComparable<T>
int GreaterCount<T, U>(IEnumerable<T> items, T x)
where T : U
where U : IComparable<U>
Both methods returns the amount of elements in items
which are greater than x
.
Explain in your own words what the type constraints mean for both methods.
Implement and test the latter of the two methods including a type hierarchy which supports the given type constraints.
Implement and test the following methods:
IEnumerable<T> Flatten<T>(IEnumerable<IEnumerable<T>> items)
IEnumerable<T> Filter<T>(IEnumerable<T> items, Predicate<T> predicate)
-
Flatten
takes as argument a stream of a stream ofT
's. It should return a stream ofT
's. -
Filter
takes as arguments a stream ofT
's and a function which returnstrue
orfalse
when applied to an instance ofT
. It returns a stream of only theT
s where the predicate returnstrue
.
You must yield
elements and not use a temporary in-memory collection.
You can declare a Predicate
likes this:
public static void Main(string[] args)
{
Predicate<int> even = Even;
}
public static bool Even(int i)
{
return i % 2 == 0;
}
Implement and test the following methods:
IEnumerable<string> SplitLine(IEnumerable<string> lines)
IEnumerable<(int width, int height)> Resolutions(IEnumerable<string> resolutions)
IEnumerable<string> InnerText(string html, string tag)
-
SplitLine
takes as argument a stream of lines (strings) and returns a stream of the words on those lines (also strings). A 'word' is a non-empty contiguous sequence of the letters a–z or A–Z or the digits 0–9. Use a regular expression to split the lines into words. -
Resolutions
takes a string containing resolutions. A resolution could be1920x1080
. It returns a stream of resolutions as tuples, e.g.(1920, 1080)
. The solution must use named capture groups.Sample input (one line represents an element in the
IEnumerable
):1920x1080 1024x768, 800x600, 640x480 320x200, 320x240, 800x600 1280x960
Sample output:
(1920, 1080) (1024, 768) (800, 600) (640, 480) (320, 200) (320, 240) (800, 600) (1280, 960)
-
InnerText
takes as arguments a string containing HTML and a specific tag name. It returns the inner text of each of those tags. Use a regular expression with a back reference to match tags.
You must yield
elements and not use a temporary in-memory collection.
Given the following html
and the tag a
:
<div>
<p>A <b>regular expression</b>, <b>regex</b> or <b>regexp</b> (sometimes called a <b>rational expression</b>) is, in <a href="/wiki/Theoretical_computer_science" title="Theoretical computer science">theoretical computer science</a> and <a href="/wiki/Formal_language" title="Formal language">formal language</a> theory, a sequence of <a href="/wiki/Character_(computing)" title="Character (computing)">characters</a> that define a <i>search <a href="/wiki/Pattern_matching" title="Pattern matching">pattern</a></i>. Usually this pattern is then used by <a href="/wiki/String_searching_algorithm" title="String searching algorithm">string searching algorithms</a> for "find" or "find and replace" operations on <a href="/wiki/String_(computer_science)" title="String (computer science)">strings</a>.</p>
</div>
The InnerText
method should return:
- theoretical computer science
- formal language
- characters
- pattern
- string searching algorithms
- strings
You should support nested html tags such that given the following html
and the tag p
:
<div>
<p>The phrase <i>regular expressions</i> (and consequently, regexes) is often used to mean the specific, standard textual syntax for representing <u>patterns</u> that matching <em>text</em> need to conform to.</p>
</div>
The InnerText
method should return:
The phrase regular expressions (and consequently, regexes) is often used to mean the specific, standard textual syntax for representing patterns that matching text need to conform to.
What is meant by “knowledge acquisition is not sequential”? Provide a concrete example of knowledge acquisition that illustrates this.
Specify which of the following decisions were made during requirements or system design:
- “The ticket distributor is composed of a user interface subsystem, a subsystem for computing tariff, and a network subsystem managing communication with the central computer.”
- “The ticket distributor will use PowerPC processor chips.”
- “The ticket distributor provides the traveler with an on-line help.”
In the following description, explain when the term account is used as an application domain concept and when as a solution domain concept:
"Assume you are developing an online system for managing bank accounts for mobile customers. A major design issue is how to provide access to the accounts when the customer cannot establish an online connection. One proposal is that accounts are made available on the mobile computer, even if the server is not up. In this case, the accounts show the amounts from the last connected session."
A passenger aircraft is composed of several millions of individual parts and requires thousands of persons to assemble. A four-lane highway bridge is another example of complexity. The first version of Word for Windows, a word processor released by Microsoft in November 1989, required 55 person-years, resulted into 249,000 lines of source code, and was delivered 4 years late. Aircraft and highway bridges are usually delivered on time and below budget, whereas software is often not. Discuss what are, in your opinion, the differences between developing an aircraft, a bridge, and a word processor, which would cause this situation.
Specify which of these statements are functional requirements and which are nonfunctional requirements:
- “The TicketDistributor must enable a traveler to buy weekly passes.”
- “The TicketDistributor must be written in Java.”
- “The TicketDistributor must be easy to use.”
- “The TicketDistributor must always be available.”
- “The TicketDistributor must provide a phone number to call when it fails.”
What is the purpose of modeling?
To submit the assignment you need to create a .pdf document using LaTeX containing the answers to the questions and a link to a public repository containing your fork of the completed code.