Trainee Class Methods
Refer the below Class outline and implement the methodspublic boolean findTrainee(Trainee trainee[],int traineeId)
public Trainee getTrainee(Trainee trainee[],int traineeId)
public int getCount(Trainee trainee[],String location)
public Trainee[] getAllTrainees(Trainee trainee[],String sequence)
public int[] getAllId(Trainee trainee[])
Toy Class
Create Class Toy with below attributesname
category
price
discount
Create Class ToyDemo with main method. Create four toy objects with relevant data. Two objects should have category as “fruits” and other two objects should have category as “animal”. Write a method in this class which will take all four toy objects as input. Additionally, it will also take category name as input. This method should return least price toy name (considering the discount as well) for specified category. If there is no specific category (e.g category as “fruits”, method should return message “no category found”.
Follow class outline diagram as given below. Ensure class attributes are private and other methods are public. Use package “com” to build your solution.
NOTE: Use .equals for comparing String values instead of == operator. Search on net and find out why. Else discuss among colleagues.
Car Class
Create class Car with below attributes: makemodel
passenger
Capacity
onRoadPrice
Create class CarDemo which has main method. Create another method - getBestCar in this class which will take four car objects and additional parameter as compareType. Value of this parameter can be ‘c’ or ‘p’, where ‘c’ stands for capacity of passengers and ‘p’ stands for on road price. This method will return make and model name for highest value of ‘c’ or ‘p’ (with – character in between. E.g for make – Hyundai and model – santro, method should return “Hyundai-santro”). Create four objects of Car class in main method and drive it through getBestCar method.
Follow class outline diagram as given below. Ensure class attributes are private and other methods are public. Use package “com” to build your solution.
Credit Card Company Class
Create class Customer with below attributes:custId
accountId
creditCardCharges
Create another class CreditCardCompany which has a method which takes Customer object as parameter and returns the payback amount for the credit card charges value for that customer. Use below logic to calculate payback amount:
a) 0.25% for charges up to Rs. 500.
b) 0.50% for the next Rs.1000 (that is, the portion between Rs. 500 and Rs. 1500),
c) 0.75% for the next Rs.1000 (that is, the portion between Rs. 1500 and Rs. 2500),
d) 1.0% for charges above Rs2500.
Thus, a customer who charges Rs. 400 a year receives Rs.1.00, which is 0.25 • 1/100 • 400, and one who charges Rs1, 400 a year receives Rs. 5.75, which is 1.25 = 0.25 • 1/100 • 500 for the first Rs. 500 and 0.50 • 1/100 • 900 = 4.50 for the next Rs. 900. Determine by hand the pay backs amount for a customer who charged Rs. 2000 and one who charged Rs. 2600.
Create another class as CreditCardDemo which will have main method. Within main method, create object of CreditCardCompany. Create 5 customer objects with relevant data. Call the method to return payback amount for each customer and display the same
Make sample classes for Car toy, Dinosaur Toy, Truck Toy and Crane Toy,
ReplyDeletethat can perform all the above-mentioned functions.
• Make a Remote class that can control all the toys.
• Use UML notations to describe the classes.
• Write the implementation of the remote class.
• Define the contract of the different methods of the Remote Class.
• Make sure to follow Java’s coding conventions.
• Make sure to properly encapsulate the fields and methods.