Swift programming language
Write a class Pet with two properties and two methods of your choice. Then write a subclass Cat which inherits from Pet. Cat should override at least one method from Pet, and should have at least one extra method and one extra property unique to Cat.
class Pet
{
var Noise: String
var color: String
init(Noise: String, color: String)
{
print(" super class
constructor")
self.Noise = Noise
self.color = color
}
func setNoise(Noise:String)
{
self.Noise=Noise
}
func display()
{
print("Noise = " +
self.Noise)
print("color = " +
self.color)
}
}
class Cat : Pet
{
var legs: Int = 0
convenience init(Noise: String, color: String,legs:
Int)
{
self.init(Noise: Noise, color:
color)
self.legs = legs
}
override func display()
{
super.display()
print("Number of legs = ",
self.legs)
}
func printnoise()
{
print("Noise:"+super.Noise)
}
}
var c1 = Cat(Noise: "MEW MEW",
color: "RED",
legs: 4)
c1.display()
c1.printnoise()
Swift programming language Write a class Pet with two properties and two methods of your choice....