Create an Address Book application using Java Swing that allows users to manage their contacts. The application should have the following features:
-
A main window with a table to display the list of contacts. The table should have columns for Name, Phone Number, and Email.
-
Buttons to add a new contact, edit an existing contact, and delete a contact.
-
A form or dialog box to add or edit a contact. The form should have fields for Name, Phone Number, and Email.
-
Validations should be performed to ensure that the Name field is not empty, and the Phone Number and Email fields have valid formats.
-
When a contact is selected from the table, the details should be displayed in the form or dialog box for editing.
-
Contacts should be stored in memory (no need for a database).
-
Your task is to implement the above features and create a functional Address Book application. Here are some guidelines to follow:
-
Use appropriate layouts and components from the Swing library to design the user interface.
-
Implement event listeners and handlers to handle button clicks and perform the necessary operations.
-
Use appropriate data structures to store the contacts in memory, such as a list or an array.
-
Implement validation logic to ensure the user enters valid data.
-
Ensure proper separation of concerns by organizing the code into classes and methods based on their functionality.
-
Apply appropriate exception handling to handle any errors or exceptions that may occur.
Output:
You are tasked with creating a client-server application that simulates a simple file transfer system. The system consists of a client program and a server program. The client program sends a file to the server, which then saves the file on the server's disk.
Your task is to implement the following:
-
Create an abstract class called FileTransfer with the following methods:
- void sendFile(String filename): This method should send the specified file to the server.
- abstract void saveFile(byte[] fileData, String filename): This method should be implemented by subclasses to save the file data on the server.
-
Create an interface called FileTransferListener with the following methods:
- void onFileSent(String filename): This method should be called when a file is successfully sent to the server.
- void onFileSaved(String filename): This method should be called when a file is successfully saved on the server.
-
Create a class called FileTransferClient that extends the FileTransfer class. This class should implement the client-side functionality. It should have the following methods:
- void sendFile(String filename): This method should send the specified file to the server using socket programming.
-
Create a class called FileTransferServer that extends the FileTransfer class. This class should implement the server-side functionality. It should have the following methods:
- void start(): This method should start the server and listen for incoming file transfers.
- void saveFile(byte[] fileData, String filename): This method should save the received file data on the server's disk.
-
Implement the FileTransferListener interface in both the client and server classes. In the appropriate methods, print messages indicating that a file has been sent or saved.
Write the necessary code to implement the FileTransfer, FileTransferClient, and FileTransferServer classes, and demonstrate their functionality in your solution.
Note: You can assume that the client and server are running on the same machine for simplicity.
- The programs should be within the package com.amrita.<>
- All the Exercises should be delivered as executable JAR file after testing. FileName of JAR should be ROLLNUMBER_DATE_EXNAME.JAR
- Create a simple calculator which takes two numbers as input and third input selecting the operation (addition, subtraction, multiplication and division). Handle all the negative usecases and print appropriate error messages.
- Create a program to print the below
* * * * * * ==================================
* * * * * ===================================
* * * * * * ==================================
* * * * * ===================================
* * * * * * ==================================
* * * * * ====================================
* * * * * * ==================================
* * * * * ===================================
* * * * * * ==================================
==============================================
==============================================
==============================================
==============================================
==============================================
==============================================
- Create a simple convertor for decimal to binary and hexadecimal. For a given input in decimal, the output should be binary and hexadecimal. Note: Only Integrer input accepted. Handle all negative usecases and print appropriate error messages.