CIS 234N C# Programming

Part 2 Assignment

This assignmnent has two projects. You can zip each one separately and upload them to the assignments box.

 

 

Project 1: Classes, Inheritance, Interfaces

 

Because these topics are so important this project makes use of all of them. For this project create a console application (not a Windows application.) 

 

As you know, .NET does not support multiple inheritance. Interfaces overcome that deficiency.

 

  1. Create an interface named IMaintenance. Specify a method named fillUp.

 

  1. Create a parent class named Vehicle. Specify a method named drive.

 

  1. Create a child class named Automobile. It should inherit from Vehicle and implement IMaintenance.

 

  1. Create a class to test with named anything you want. In this test class create a new Automobile object. Invoke the drive and fillUp methods to be sure they work.

 

  1. Now that you have this much done you can expand the project. Modify the drive method so that it accepts a value of number of miles to drive. Also, for each mile driven, reduce the amount of gas in the tank by some amount. How you do this is up to you but keep it simple.

 

  1. Modify the fillUp method to accept an input of number of gallons to put in the tank.

 

If the Automobile object drives and runs out of gas a message should appear saying that. (Use Console.Writeline for the message.)

 

Project 2: Arrays

 

Modify the ArrayOfObjectsExample project. Create a new console application that is like the example project. Instead of a Cartoon class, create a new class of your own. Keep the new class simple with only two fields in it.  Make sure the testing class creates 2 objects from your new class and displays their values.