0% found this document useful (0 votes)
1 views4 pages

Example 2

The document outlines the development of a vehicle management feature, including the creation of Vehicle and Ticket classes with specified attributes and methods. It details the implementation of a VehicleBO class for searching vehicles by type and parked time. Sample test cases illustrate how to input vehicle data and perform searches, displaying results or appropriate messages based on user input.

Uploaded by

starbabu311
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

Example 2

The document outlines the development of a vehicle management feature, including the creation of Vehicle and Ticket classes with specified attributes and methods. It details the implementation of a VehicleBO class for searching vehicles by type and parked time. Sample test cases illustrate how to input vehicle data and perform searches, displaying results or appropriate messages based on user input.

Uploaded by

starbabu311
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

In this requirement develop a feature in which you can search a List of Vehicles by type and parkedTime.

a) Create a Class Vehicle with the following attributes:

Member Field Name Type

_registrationNo string

_name string

_type string

_weight Double

_ticket Ticket

Mark all the attributes as private. Create / Generate appropriate properties.

Add a default constructor and a parameterized constructor to take in all attributes in the given order:

Vehicle( string _registrationNo, string _name, string _type, Double _weight ,Ticket _ticket)

Create the following static method in Vehicle class, Method Name Description

public static Vehicle CreateVehicle(string detail)

This method accepts a string which contains vehicle details separated by commas. Split the details and
create a vehicle object from the details and return it.

The Vehicle and Ticket details should be given as a comma-separated value in the below order,
_registrationNo, _name, _type, _weight, _ticketNo, _parkedTime, _cost

b) Create a Class Ticket with the following attributes:

Member Field Name Type

_ticketNo string

_parkedTime DateTime

_cost Double

Mark all the attributes as private.


Create / Generate appropriate properties, Add a default constructor and a parameterized constructor to
take in all attributes in the given order:

Ticket( String _ticketNo, Date _parkedTime, Double _cost)

c) Create a class VehicleBO with the following methods,

Method Name Description

public List<Vehicle> FindVehicle(List<Vehicle> vehicleList, string type)

This method accepts a list of vehicles and type as arguments and returns a list of vehicles that matches with
the given type.

public List<Vehicle> FindVehicle(List<Vehicle> vehicleList, DateTime parkedTime)

This method accepts a list of vehicles and parkedTime as arguments and returns a list of vehicles that
matches with the given parkedTime.

The Vehicle and Ticket details should be given as a comma-separated value in the below order,
registrationNo, name, type, weight,ticketNo,parkedTime,cost

When the “vehicle” object is printed, it should display the following details

Print format:

Registration No:"_registrationNo"

Name:"_name"

Type:"_type"

Weight:"_weight"

Ticket No:"_ticketNo"

The vehicle lists are displayed in the main method.

If any other choice is selected, display "Invalid Choice"

If the search detail is not found, display "No such vehicle is present"
Sample test case 1:

Enter the number of vehicles:

AP 19 QS 4556,R3,TwoWheeler,196,A1-002,10-05-2018 11:05:21,100
MP 01 LK 0001,Hornet,TwoWheeler,163,A1-009,09-05-2018 08:13:24,50
MH 23 F 7856,Gixer,TwoWheeler,221,A1-013,11-05-2018 05:21:40,75
GA 45 RF 9515,Duke,TwoWheeler,240,A1-024,10-05-2018 05:16:26,75
GJ 83 AX 0545,Ciaz,FourWheeler,530,B4-030,10-05-2018 08:25:33,150
HR 46 S 4523,Swift,FourWheeler,846,B4-021,09-05-2018 07:14:13,200

Enter a search type:

1. By type
2. By parked time

Enter the vehicle type

FourWheeler

Registration No Name Type Weight Ticket No

GJ 83 AX 0545 Ciaz FourWheeler 530.0 B4-030


HR 46 S 4523 Swift FourWheeler 846.0 B4-021

Sample test case 2:

Enter the number of vehicles:

AP 19 QS 4556,R3,TwoWheeler,196,A1-002,10-05-2018 11:05:21,100
MP 01 LK 0001,Hornet,TwoWheeler,163,A1-009,09-05-2018 08:13:24,50
MH 23 F 7856,Gixer,TwoWheeler,221,A1-013,11-05-2018 05:21:40,75
GA 45 RF 9515,Duke,TwoWheeler,240,A1-024,11-05-2018 05:21:40,75
GJ 83 AX 0545,Ciaz,FourWheeler,530,B4-030,10-05-2018 08:25:33,150
HR 46 S 4523,Swift,FourWheeler,846,B4-021,09-05-2018 07:14:13,200
Enter a search type:

1. By type
2. By parked time

Enter the parked time:

11-05-2018 05:21:40
Registration No Name Type Weight Ticket No
MH 23 F 7856 Gixer TwoWheeler 221.0 A1-013
GA 45 RF 9515 Duke TwoWheeler 240.0 A1-024

You might also like