Q1_20251109103345.webp
May76

Q1_20251109103345.webp

  • Media owner May76
  • Ngày thêm
(3 marks) Write a class Car and a class SpecCar extending from Car (i.e. Car is a superclass and
SpecCar is a subclass) with the following information:
-color:String
-seat:int
Car
Where:
.
getColor():String - return color.
getSeat():int-return Seat.
2 of 2
+Car()
Paper No: 3
+Car(color:String, seat:int)
+getColor():String
+getSeat():int
+setColor(color:String):void
⚫ setColor(color:String):void - update color.
⚫ toString(): String-return the string of format:
color, seat
+toString():String
SpecCar
-model:String
+SpecCar()
+SpecCar(color:String, Seat:int, model:String)

+getModel():String
+toString():String
+setData():void
+getValue():String
Zoom
- FUO
+ 100%
.
Where:
toString():String return the string of
format:
color, seat, model
getModel():String - return model.
setData():void Remove the first letter
in the color string.
⚫ getValue():String - Check if the seat is
an odd number then return model after
removing characters at odd indices (1-
based means i+1, ex: bmw have 3
characters and the character 'b' is 1, 'm'
is 2...) from model, otherwise return
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
May76
Ngày thêm
Lượt xem
2,797
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom