1. Design and implement a C# class Time
that
represents a time of day with 1-second resolution, e.g. 11:32:07.
Your class should include the following:
a constructor that takes three integers (hours, minutes, seconds)
a constructor that takes two integers (hours, minutes), assuming 0 seconds
a method that adds a number of seconds to a Time
,
yielding a new Time
object (wrapping past midnight if
necessary)
a method that subtracts two Time
objects,
yielding a (possibly negative) number of seconds
a ToString() method that yields a string such as "11:32:07"
a static method Parse() that parses a string such as
"11:32:07", yielding a Time
2. Design and implement a C# class Vector
that
represents a vector in n-dimensional space. Your class should include
the following:
a constructor that takes a variable number of arguments of
type double
, yielding a vector with those components
a method that adds two vectors
a method that multiplies a scalar times a vector, yielding a new vector
a method that computes the dot product of two vectors, yielding a scalar
a method that computes the length of a vector
a method that computes the angle between two vectors in radians
a ToString() method that yields a string such as "[3.25 5.02 -6.12]", with two digits after the decimal point in each component
a static method Parse() that parses a string such as "[3.25 5.02 -6.12]", yielding a vector
3. Design and implement a C# class Polynomial
representing a polynomial of a single variable. Your class should
include the following:
a constructor that takes a variable number of arguments of
type double
, yielding a polynomial with those
coefficients. For example,
new Polynomial(1.0, 4.0, 5.0)
should yield the polynomial x2 + 4x + 5.
a method that adds two polynomials
a method that multiplies two polynomials
a method that evaluates a polynomial for a given value of x
a method that returns the first derivative of a polynomial
a method that returns the k-th derivative of a polynomial for a given k
a ToString() method that yields a string such as "x^2 + 4x + 5"
a static method Parse() that parses a string such as "x^2 + 4x + 5", yielding a polynomial