Reference no: EM133201514
This Assignment Description contains three programming assignments. Below are the programming assignments from the concepts learnt. Each assignment has a problem description, and you are required to discussion, to be complete / to solve the problem.
Programming Assignment 1
Write a program named SalespersonDemo that instantiates objects using classes named RealEstateSalesperson and GirlScout. Demonstrate that each object can use a SalesSpeech() method appropriately. Also, use a MakeSale() method two or three times with each object, and display the final contents of each object's data fields. First, create an abstract class named Salesperson. Fields include first and last names; the Salesperson constructor requires both these values. Include properties for the fields. Include a method that returns a string that holds the Salesperson's full name-the first and last names separated by a space. Then perform the following tasks:
- Create two child classes of Salesperson: RealEstateSalesperson and GirlScout. The RealEstateSalesperson class contains fields for total value sold in dollars and total commission earned (both of which are initialized to 0), and a commission rate field required by the class constructor. The GirlScout class includes a field to hold the number of boxes of cookies sold, which is initialized to 0. Include properties for every field.
- Create an interface named ISellable that contains two methods: SalesSpeech() and MakeSale(). In each RealEstateSalesperson and GirlScout class, implement SalesSpeech() to display an appropriate one- or two-sentence sales speech that the objects of the class could use.
In the RealEstateSalesperson class, implement the MakeSale() method to accept an integer dollar value for a house, add the value to the RealEstateSalesperson's total value sold, and compute the total commission earned. In the GirlScout class, implement the MakeSale() method to accept an integer representing the number of boxes of cookies sold and add it to the total field.
Programming Assignment 2
Create a program named PaintingDemo that instantiates an array of eight Room objects and demonstrates the Room methods. The Room constructor requires parameters for length, width, and height fields; use a variety of values when constructing the objects. The Room class also contains a field for wall area of the Room and number of gallons of paint needed to paint the room. Both of these values are computed by calling private methods. Include read-only properties to get a Room's values. A room is assumed to have four walls, and you do not need to allow for windows and doors, and you do not need to allow for painting the ceiling. A room requires one gallon of paint for every 350 square feet (plus an extra gallon for any square feet greater than 350). In other words, a 12 X 10 room with 9-foot ceilings has 396 square feet of wall space, and so requires two gallons of paint.
Programming Assignment 3
Remember, strings are immutable. Consider a string that represents a strand of DNA: string dna = " TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT". There are some typos in the string that we would like to fix:
- Use the Trim() method to remove the leading and trailing whitespace, and then print the results.
- Change all of the letters in the dna string to UPPERCASE and print the result.
- Note that if you try Console.WriteLine(dna) after applying the methods, the original, flawed string is displayed. To fix this, you need to reassign the changes back to dna. Apply these fixes to your code so that Console.WriteLine(dna) prints the DNA strand in UPPERCASE with no whitespace.
Let's use string methods to do more work on the DNA strand:
- Replace the sequence "GCT" with 'AGG', and then print the altered strand.
- Look for the sequence "CAT" with IndexOf(). If found print, "CAT found", otherwise print, "CAT NOT found".
- Use Substring() to print out the fifth set of 3 characters (called a codon) from the DNA strand.
- Use string interpolation to print, "The DNA strand is ___ characters long.
If we want to turn the string "C Sharp" into "CS", we might try .Remove(). Too easy. Let's use our cleverness to achieve the same result and practice with other C# methods.
- Use string concatenation and two Substring() methods to print "CS" from "C Sharp".
- Without using Substring(), use method chaining to accomplish the same thing.
- Use bracket notation and string interpolation to print, "The abbreviation for "C Sharp" is "CS." Don't forget about your escape characters.