Chapter 11 Write one program that includes all three exercises. 1. Create a base
ID: 3704239 • Letter: C
Question
Chapter 11
Write one program that includes all three exercises.
1. Create a base class to hold information about sporting teams on campus. It should not be possible to instantiate the class. Include common characteristics such as primary coach and type of sport. Define properties, ToString( ) methods, and a minimum of one virtual method. The ToString( ) method should return the name of the sport and coach.
2. Define subclasses for two types of sporting teams. These classes should inherit from a base team class such as that created in Exercise 1. Include unique characteristics about the sport. For example, for a sporting team such as a tennis team, the field location and/or the person to contact to restring rackets may be of interest. Be sure to implement any virtual methods included in the base class. Provide ToString( ) methods in both subclasses that invokes the ToString( ) method in the base class and adds unique characteristics about the individual team to the return value.
3. Add a new project to the solution you designed for Exercises 1 and 2. The new project should test your designs of the base team class and individual sporting team subclasses. Your class can be a console or Windows application. One approach would be to instantiate objects of both teams when the program launches and then invoke methods and properties to retrieve and display data about both teams. Be sure to retrieve data from the base class as well as the subclasses.
Chapter 12 Programming Exercise #2 (page 835):
Write an exception tester application that enables you to see the impact of exceptions being thrown. Include multiple catch clauses. You might investigate classes such as ArithmeticException, FormatException, IndexOutOfRangeException, and Exception. For each exception, write a try block containing errors to throw the exceptions. As you test the application, include an error that throws the exception and then comment it out and program an error that throws the next exception and so on. Your final solution should include at least one statement per exception that throws each exception. The statements should all be commented out by the time you finish testing. Be sure to include documenting comments with each statement.
Please complete these assignments as actual C# applications so you can compile and run them to see if you have any errors.
This is for C#
Explanation / Answer
Hi Dear Friend,
Question is long, as per the chegg guideline, please post each part in separate post.
I have implemented Q1 of Chapter 11.
Please repost others in separate post.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SportInfo_cs
{
class sport
{
public String coach, sportType;
public sport(String c, String t)
{
coach = c;
sportType = t;
}
public virtual String ToString()
{
String s;
s = coach+sportType;
return s;
}
}
class Program
{
static void Main(string[] args)
{
sport o = new sport("Ravi","Cricket");
String s;
s=o.ToString();
Console.WriteLine ("Sport Coach and Type = " + s);
Console.ReadKey ();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.