TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jibin Matthew
NA
6
2k
Problem regarding inheritance
Apr 25 2013 8:35 AM
Write a program to define a class College BUS and a class BusEngine .Let the CollegeBus class contain BusEngine .The BusEngine should be started at the College Campus and stopped after reaching the destination (say Y ) .Let the speed and the distance be read.The Program should throw an exception when the CollegeBus tries to travel beyond destination or speed increase beyond 100 kmper hour. Develop the application in C#.
i am not understanding my mistake
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class CollegeBus
{
public static int speed;
public static float distance;
public CollegeBus(int s, float d)
{
speed = s;
distance = d;
}
}
public class Engine : CollegeBus
{
string str1;
string str2;
public Engine(string s1, string s2)
: base(speed, distance)
{
str1 = s1;
str2 = s2;
Console.WriteLine("Source is {0} and destination is {0}",s1,s2);
if (distance > 30)
throw new DistanceExceededException();
if (speed > 100)
throw new SpeedExceededException();
}
}
class Travel
{
public static void Main()
{
CollegeBus b=new CollegeBus(40,20);
//Engine e=new Engine("X","Y");
b.Engine.str1=40;
b.Engine.str2=20;
}
Reply
Answers (
2
)
Hide or show label based on seach.
queues