Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Assignment-5
Base on Java Annotation
1. Create an interface ‘PaymentProcessor’ with a method String
processPayment(double amount,String currency). Create 3 classes named creditCardProcessor, payPalProcessor,and BankTransferProcessor each implementing the PaymentProcessor interface. In each class, override the processPayment method to return a string that includes the type of paymentprocessor(eg.credit crd),the amount, and currency. Create a class named PaymentService that contains a dependency on the PaymentProcessor interface and a method void makePayment(double amount, String currency) that calls the processPayment method. The method should print a message “processing creditcard payment of 100.0USD. Use setter method to add dependencies. Use annotation based configuration and create different beans to populate PaymentProcessor with the creditCardProcessor, PayPalProcessor, and BankTransferProcessor classes.Write a Run class of Spring application to execute the application. 2. Write a java program to create a class Book with private data members such as bookName, authorName,and edition. Use setter and getter, and display method. Create a annotation based configuration and display book detail in the main class of Spring Application. 3. Create class named as Student which contain a method printMessage(String name) and it returns Hello yourname. Create a bean object of this class and call the method printMessage in the main class of Springboot Application by using following ways a. By implementing CommandLineRunner interface method. b. Without implementing commandLineRunner.(use separate configuration class) 4. Create a constructor called MyClass which consists of following attributes Name, regdNo, subjectName and markSecured. Write a display() method which displays above details. Create 2 bean object of the constructor for two students and call the display method in the main class of Springboot Application by using both ways of 3.a and 3.b. 5. Create a package of 4 classes named as address, Teacher, app, javaConfig. Address has fields as houseNo, city, postOffice, pin, state. Use setter method for the given fields and toString method to print string representation of the object. Teacher class has name, id, mobileNo, and address fields. Use the setter method and toString method for this class. javaConfig class is java annotation-based configuration file which creates two address beans and on teacher bean and initialize the fields of both classes. In teacher class use any one address by using @Qualifier annotation. Call the teacher object in app class which consists of main method of Spring application. 6. Create a customer class which consists of customerName, accountNo, IFSCCode, use setter method and override the toString Method. Create a configuration class(annotation based) named as conFig. Use configuration and componntscan Annotatuion and create a bean for customer class and initialize the field by calling setter method of customer class. Display details of customer in the app/run class which consists of main method of SpringApplication. 7. Create a class named as Book having fields title, price, pDate(reference of class pubDate) and override the toString Method. Use @value ,@Autowire @Component and @override annotation in appropriate position. The class pubDate consists of filed day, month, and year. Use @value to give value of each field and write toString method. Display book details in the main method of app.java of Spring Application. 8. Create a class and use appropriate annotation to display your name in browser when user type.localhost:8080/home.
(Ebook) SAP ABAP Objects: A Practical Guide to the Basics and Beyond by Rehan Zaidi ISBN 9781484249642, 148424964X - Read the ebook online or download it for a complete experience
Instant ebooks textbook Clean Code with C# - Second Edition: Refactor your legacy C# code base and improve application performance using best practices Alls download all chapters