Questions: 1 835

Answers by our Experts: 1 539

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

lab-13:-

Using Serialization to persist business data


Q1. You have already created the Contact class. You need to store List of Contacts in binary format on disk. Perform Binary Serialization to store the List. To Do: Write the Program to Accept the data for multiple contacts, store them in a List. Serialize the List using Binary formatter.


Q2. The Client has suggest an Enhancement to the above code. You need to write the code to Deserialize the data from the Binary file, and print the details.


File Copy operation. You need to accept source and destination file names. data should be copied from source file to destination file. Handle all exceptions that might occur during file copy operation.


Extended Assignment

An institute have decided to automate their batch details operations. Application is to be developed

in proper directory structure to be maintained to store files.

EX:-

Academy:

Chennai: Chennai.txt

Bangalore: Bangalore.txt

Mumbai: Mumbai.txt

Pune: Pune.txt

Operations:

Create a menu based application to store batch details.


• First option in menu should allow user to create directory structure and files (if not exists) in c drive as shown in above figure.

• Second option should accept batch details from user. Based on location given by user append batch details in respective files.

• Third menu option allows user to create a backup copy of Academy folder in D Drive

• Fourth option should allow user to view details of text files as mentioned above.


Write a Code to Read and Display the contents of a text file. Accept the name of the file from the user. Handle all the exceptions that might occur during reading.


The code has some bugs. It is supposed to raise an event, whenever the File is downloaded


delegate void DownloadCompeteHandler(int perc);

public class FileDownloader

{

protected string resourceUrl;

protected string resourceSavePath;

event DownloadCompeteHandler DownLoadComplete;

public FileDownloader(string url,string savepath)

{

this.resourceUrl = url;

this. resourceSavePath = savepath;

}

public void DownLoadResource()

{

for (int i = 1; i <= 4; i++)

{

for (int j = 1; i <= 10000; i++);

OnDownLoadComplete(i * 25);

}

}

protected void OnDownLoadComplete( )

{

if (DownLoadComplete == null)

DownLoadComplete( );

}

}

public static void Main(string[] args)

{

FileDownloader fd =

new FileDownloader("http://www.microsoft.com/vstudio/expressv10.zip", "d:\\setups");

fd.DownLoadComplete += new Handler();

fd.DownLoadResource();

Console.ReadKey();

}

static void fd_DownLoadComplete(int perc)

{

Console.SetCursorPosition(10, 10);

Console.Write("Downloading {0} Percent Complete", perc);

}


Lab-11

Q1. ICICI Bank want’s to implement SMS alert fascility to the customers whenever they pay the Credit Card Bill. The CreditCard class contains the following fields.

CreditCardNo, CardHolderName, BalanceAmount, CreditLimit.


The class has three functions. GetBalance(), GetCreditLimit(), and MakePayment(). Whenever the MakePayment() method is called, it should update the BalanceAmount and raise an event. The event should send a message. ( You don’t need to write a logic to send the sms. Only print the message saying amount is credited.)


Task to be performed:

Define a class CreditCard

Define a Delegate to Handle the Event

Define an event which will be raised whenever the payment is made.

Create a Console client application, and try the functionality.


Q2. Do a peer review of this code and suggest if any improvements can be done.


Task : Mahesh has suggested that we should define one function called PerformArithmeticOperation( ) which will take 2 numbers and the Delegate as parameters. Instead of calling / executing the delegate from Main() function, let this function manage the delegate call. You have to implement this functionality.


Hint: The PerformArithmeticOperation() function signature is:

static void PerformArithmeticOperation( int num1, int num2, MyDelegate arOperation){…}


Lab-10

Q.1) You need to perform Arithmetic operations on two numbers. The operations include Add Numbers, Multiply Numbers, Divide Numbers, Subtract Numbers and Find Max Number.


Task 1: Define a class ArithmeticOperation having the above methods.


Task 2: Define a Delegate which can call these methods.


Task 3: Create a console application to accept two numbers and arithmetic operation to be performed from the user. Based on the choice, the Delegate instance will hold the address of the appropriate method.


Task 4: Execute the delegate to get the required result.


You need to maintain file extensions along with file types in dictionary class

Tasks:

• Create a new dictionary of strings, with string keys.

• Add some elements to dictionary. There should not be duplicate keys, but some of values can be duplicates.

• The Add method throws an exception if new key is already in dictionary. Test this by adding a duplicate key.

• The indexer can be used to change value associated with a key. Try changing the value of any record and display the updated value.

• If a key does not exist, setting the indexer for that key adds a new key/value pair. Try this by adding a new value.

• The indexer throws an exception if requested key is not in dictionary. Try printing any such key which is not present and handle exception.

• When you use foreach to enumerate dictionary elements, the elements are retrieved as Key/Value Pair objects. Use a foreach loop to print the values and test this.

• Use the Remove method to remove a key/value pair.


Sameer has written a code to create the Hash Table. The code is given below.

class Program

{

static void Main()

{

}

static Hashtable GetHashtable()

{

// Create and return new Hashtable.

Hashtable hashtable = new Hashtable();

hashtable.Add("Area", 1000);

hashtable.Add("Perimeter", 55);

hashtable.Add("Mortgage", 540);

return hashtable;

}

}

You need to perform some tasks on this code. Write the functionality in the main method.

Task 1: See if the Hashtable contains the key “Perimeter”.

Task 2: Print the value of “Area” with indexer.

Task 3: Remove the entry for “Mortgage”


We need to maintain the list of RTO districts. e.g. MH01 – Mumbai, MH 04 – Thane etc. Write a program which uses a Hashtable to maintain this list.


Task 1: Create a console application to maintain the list. It should display a menu to perform the following tasks:

• Add Record in Hashtable

• Search record

• Display All Records

• To display Total count of Records at any point

• Remove any particular record


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS