Im in school and need help with my coding. Teacher is no help so was hoping some one can correct my code. I'm trying to develop a simple inheritance hierarchy that has an abstract base class that includes an abstract method.

Abtract Class:
Code the abstract base class called MusicPlayer that has the abstract method: Play( ). Include at least two state variables that are appropriate to the abstract base class and define accessor/mutator methods or properties for every state variable included in the class.

Derived class:
Complete the abstraction for the iPod class and code it.

Main Method:
Code a Main method to test the Play( ) method in the derived class.

My Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
    public abstract class MusicPlayer
        protected string manufacture;
        protected bool price;
        public string Manufacture
            get { return manufacture; }
            set { manufacture = value; }    
        public bool Price
            get { return price; }
            set { price = value; }  
        public abstract void Play();

    public class IPod : MusicPlayer
        private string color;
        private string video;

        public Color() 
            manufacture = "Apple iPod";
            price = "On sale";
            color = "Black";
            video = "Plays movies";     
        public override void Manufacture()
           Console.WriteLine("The"+ this.manufacture+ "30Gig" + this.price+ "is on sale"+ this.color+ "black"+ this.video );    

    public class Test
        static void Main(string[ ] args)
            IPod myIpod = new Ipod();
            myIPod.Manufacture = "Apple iPod";
                       myIPod.Price = "On sale";
                       myIPod.Color = "Black";
                       myIPod.Video = "Plays movies";


Edited by Dani: Formatting fixed

8 Years
Discussion Span
Last Post by sweetyssweeto

The name of your class is IPod but i guess the constructor you made is for some Color class, not sure whether this code is working for you or not. Rename the constructor to the name of the class. Rest code seems fine to me.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.