c# - How can I use abstract method in proper manner? -
this question has answer here:
- when use abstract classes? 6 answers
i implementing library system exercise, in have created 1 abstract class :
public abstract class rentalitem { ..... public rentalitem() { } public rentalitem(string itemid, string title, int qty,float price, periodtype period) { itemid = itemid; title = title; no_of_copies = qty; period = period; } public abstract void additem(string itemid, string title, int no_of_copies,float price,periodtype p); ..... }
afterwards, have created movieitem class, inherits rentalitem class : class has fields. below :
public movie(string itemid, string title, int no_of_copies, float price, periodtype p, movietype type, string actor, string director) : base(itemid, title, no_of_copies, price, p) { this.type = type; this.actors = actor; this.director = director; } public override void additem(string itemid, string title, int no_of_copies,float price,periodtype p){};
but actully want implement additem method such away, takes base parameters + additional parameters below :
public void additem(string itemid, string title, int no_of_copies, float price, periodtype p, movietype type, string actor, string director)
so how can use abstract method? , if implementing own additem(...) method use of abstract class ?
when using abstract method have override method, means have adhere original signature of abstract method. can not add or remove parameters original signature. if need change signature, it's not appropriate use abstract method
Comments
Post a Comment