// Code your design here
virtual class trains;
protected int times = -1;
protected int price = -1;
protected string name ;
protected int seat_no = -1;
function new (int t, int p, string n, int s);
// t = times. p = price. n = name. s = seat_no
times = t;
price = p;
name = n;
seat_no = s;
endfunction : new
function int get_times();
return times;
endfunction
function int get_price();
return price;
endfunction
function string get_name();
return name;
endfunction
function int get_seat_no();
return seat_no;
endfunction
pure virtual function void station();
endclass : trains
class express extends trains;
protected string name;
function new(int times_1, int price_1, int seat_1, string name_1)
super.new(.t(times_1), .p(price_1), .s(seat_1), .n(name_1));
endfunction : new
function void station();
$display ("* THIS TRAIN DEPARTS FROM kARACHI = %s *" , get_name());
$display ("* THE TIME OF DEPARTURE IS = %0d * ", get_times());
$display ("* THE TIME OF DEPARTURE IS = %0d * ", get_price());
$display ("* THE TIME OF DEPARTURE IS = %0d * ", get_seat_no());
endfunction : station
endclass : express
class mails extends trains;
function news_2(int times_2, int_price_2, int seat_no_2, string name_2);
super.news_2(.t(times_2), .n(name_2));
endfunction : news_2
function void station();
$display ("INFORMATION");
$display ("SORRY! BUT YOUR TRAIN = %s , has been delayed", get_name());
$display (" NOW YOUR TRAIN WILL DEPARTURE AT = %0d, pm", get_times());
$display (" ELSE YOU CAN TAKE THE REFUNDS FROM THE COUNTER ");
endfunction : station
endclass : mails
class locals extends express
function news_3(int times_3, int price_3, int_seat_3, string name_3);
super.news_3(.n(name_3));
endfunction : news_3
function void station();
$display("SORRY! BUT YOUR TRAIN = %s , has been cancelled due to heavy rain", get_name());
$display (" YOU CAN TAKE YOUR REFUND BACK");
endfunction : station
endclass : locals
class passenger extends mails
function news_4(int times_3, int price_3, int_seat_3, string name_3);
super.news_4(.n(name_3), .p(price_3));
endfunction : news_4
function void station();
$display("The Price of ticket of Train = %0d ,", get_price(), "And the Name Of Train Is = %s ", get_name());
$display (" HOPE YOU WILL ENJOY YOUR TRAVEL");
endfunction : station
endclass : passenger
class my_code #(type A);
protected static A platform[$];
static function void platform_1(A a);
platform.push_back(a);
endfunction : platform_1
static function void schedule();
$display (" THE TRAINS WHICH WILL GO TODAY = ");
foreach(platform[i])
$display(platform[i].gate_name());
$display(platform[i].gate_price());
$display(platform[i].get_times());
$display(platform[i].get_seat_no());
endfunction : schedule
endclass : my_code
module top;
initial begin
express express_h;
mails mails_h;
locals locals_h;
passenger paseenger_h;
$display ("* WELCOME TO PAKISTAN RAILWAY*** ");
$display ("* Today Schedule is as under *");
express_h = news_1(10, 2250, 7, "Rehman Baba Express");
my_schedule #(express) :: platform_1(express_h);
express_h = news_1(3, 4500, 23, "Karakoram Express");
my_schedule #(express) :: platform_1(express_h);
express_h = news_1(5, 3000, 10, "Karachi Express");
my_schedule #(express) :: platform_1(express_h);
express_h = news_1(2, 1200, 11, "Allama Iqbal Express");
my_schedule #(express) :: platform_1(express_h);
express_h = news_1(7, 5500, 2, "Shah Hussain Express");
my_schedule #(express) :: platform_1(express_h);
mails_h = news_2(6, "Bolan Mail Express");
my_schedule #(mails):: platform_1(mails_h);
mails_h = news_2(7, "Awam Express");
my_schedule #(mails):: platform_1(mails_h);
locals_h = news_3("Pak Business Express");
my_schedule #(locals):: platform_1(locals_h);
locals_h = news_3( "Mehran Express");
my_schedule #(locals):: platform_1(locals_h);
locals_h = news_3( "Karachi Circular Railways");
my_schedule #(locals):: platform_1(locals_h);
passenger_h = news_4(3500, "Pak Business Express");
my_schedule #(passenger):: platform_1(passenger);
passenger_h = news_4(9500, "Sirsyed Express");
my_schedule #(passenger):: platform_1(passenger);
end
endmodule : top
error:
ERROR VCP2000 “Syntax error. Unexpected token: super[_SUPER]. This is a SystemVerilog keyword since IEEE Std 1800-2005 and cannot be used as an identifier. Use -v2k5, -v2k or -v95 argument for compilation.” “design.sv” 42 14
ERROR VCP2000 “Syntax error. Unexpected token: endclass[_ENDCLASS]. This is a SystemVerilog keyword since IEEE Std 1800-2005 and cannot be used as an identifier. Use -v2k5, -v2k or -v95 argument for compilation.” “design.sv” 56 9
ERROR VCP2000 “Syntax error. Unexpected token: function[_FUNCTION].” “design.sv” 78 15
ERROR VCP2000 “Syntax error. Unexpected token: endclass[_ENDCLASS]. This is a SystemVerilog keyword since IEEE Std 1800-2005 and cannot be used as an identifier. Use -v2k5, -v2k or -v95 argument for compilation.” “design.sv” 87 13
ERROR VCP2000 “Syntax error. Unexpected token: function[_FUNCTION].” “design.sv” 90 16
ERROR VCP2000 “Syntax error. Unexpected token: endclass[_ENDCLASS]. This is a SystemVerilog keyword since IEEE Std 1800-2005 and cannot be used as an identifier. Use -v2k5, -v2k or -v95 argument for compilation.” “design.sv” 99 13