Sie sind auf Seite 1von 3

Bank - Requirement 1

Create an application to store the details of a Bank along with the Locker details.

Requirement 1:
Let’s start off by creating two Locker objects and check whether they are equal.

1. Create a Locker Class with the following attributes:


Member Field Name Type

_number int

_lockType string

_password string

_amount double

_lastOpened DateTime
2. Mark all the attributes as private
3. Create / Generate appropriate getters and setters.
4. Add a default constructor and a parameterized constructor to take in all attributes in
the given order:
Locker ( int _number, string _lockType, string _password, double
_amount, DateTime _lastOpened )
5. When the “Locker” object is printed, it should display the following details: [Override
the ToString method]
Print format:
Number:"_number"
Lock Type:"_lockType"
Password:"_password"
Amount:"_amount"
Last Opened:"_lastOpened"
6. Two Lockers are considered same if they have the same _number, and _password.
Implement the logic in the appropriate function.
[Override the Equals method]

The input format consists of Locker details separated by comma in the below order,
_number, _lockType, _password, _amount, _lastOpened
The Input to your program would be details of two Lockers, you need to display their details
as given in "5th point(refer above)" and compare the two Lockers and display if the Lockers
are same or different.

Problem Overview:
The first two line of input consist of a string, that corresponds to the locker
details(which is comma seperated). Refer above input format.
Display the two locker details in Main method using ToString method(Refer above
format).
And also check if the two locker are same or different(Use Equals method to
compare the two objects).
Equals method return bool value to Main method(true or false).
If the Equals method returns true, then print "Locker 1 is same as Locker 2".
If the method returns false, then print "Locker 1 and Locker 2 are different".

Create a class named as Program, which contains Main method, it is used to access above
class and its method to done this requirement.
All the input and output operations are done in this requirement.

Note: There is an empty line between display statements. Print the empty lines in
the Main function.
Display one digit after the decimal point for Double datatype.

Sample Input and Output 1:


Enter locker 1 details:
587,FingerPrint,wxyz,1500,02-03-2018
Enter locker 2 details:
587,FingerPrint,wxyz,1500,02-03-2018

Locker 1
Number:587
Lock Type:FingerPrint
Password:wxyz
Amount:1500.0
Last Opened:02-03-2018

Locker 2
Number:587
Lock Type:FingerPrint
Password:wxyz
Amount:1500.0
Last Opened:02-03-2018

Locker 1 is same as Locker 2

Sample Input and Output 2:


Enter locker 1 details:
145,Keypad,abcd,1000,01-02-2018
Enter locker 2 details:
587,FingerPrint,wxyz,1500,02-03-2018

Locker 1
Number:145
Lock Type:Keypad
Password:abcd
Amount:1000.0
Last Opened:01-02-2018

Locker 2
Number:587
Lock Type:FingerPrint
Password:wxyz
Amount:1500.0
Last Opened:02-03-2018

Locker 1 and Locker 2 are different

Das könnte Ihnen auch gefallen