Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Truck class implementing Automobile interface like Sedan class
- using System;
- namespace LearnInterfaces
- {
- class Truck : IAutomobile
- {
- //PROPERTY
- public string LicensePlate
- { get; }
- public double Speed
- { get;
- private set;} //setter created
- public int Wheels
- { get; }
- public double Weight
- {get; }
- public void Honk()
- {
- Console.WriteLine("HONK!");
- }
- //CONSTRUCTOR
- public Truck(double speed, double weight){
- this.Speed = speed;
- this.Weight = weight;
- LicensePlate = Tools.GenerateLicensePlate();
- if (Weight < 400){
- Wheels = 8;
- }
- else {
- Wheels = 12;
- }
- }
- //need to add private setter in property in order to set the Speed property here in the methods
- public void SpeedUp(){
- Speed+=5;
- }
- public void SlowDown(){
- Speed-=5;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement