Files
Demo1/force-app/main/default/classes/assigment.cls
2025-04-02 17:50:49 +05:30

166 lines
4.7 KiB
OpenEdge ABL

public class assigment {
public static void getLeadQuality(Decimal annualRevenue)
{
if (annualRevenue > 2000000)
{
system.debug('High Quality');
} else if (annualRevenue >= 500000)
{
system.debug('Medium Quality');
} else
{
system.debug('Low Quality');
}
}
public static void getSuggestedMovie(String key)
{
Map<String, List<String>> movieMap = new Map<String, List<String>>
{
'Action' => new List<String>{'Mad Max', 'Gladiator', 'Die Hard'},
'Comedy' => new List<String>{'Superbad', 'Step Brothers', 'The Hangover'},
'Drama' => new List<String>{'The Shawshank Redemption', 'Forrest Gump', 'Fight Club'},
'Horror' => new List<String>{'The Conjuring', 'Get Out', 'It'},
'Sci-Fi' => new List<String>{'Inception', 'Interstellar', 'The Matrix'}
};
if (!movieMap.containsKey(key))
{
system.debug('No movies available for this genre');
}
system.debug(movieMap.get(key));
}
public static void calculateParkingFee(Integer hoursParked)
{
Decimal totalFee = 0;
for (Integer hour = 1; hour <= hoursParked; hour++) {
if (hour == 1)
{
continue;
}
else if (hour <= 4)
{
totalFee += 5;
}
else
{
totalFee += 10;
}
}
system.debug(totalFee);
}
public static Decimal calculateTotalBill(Map<String, Integer> order)
{
Map<String, Decimal> menu = new Map<String, Decimal>
{
'Pizza' => 10.00,
'Burger' => 5.00,
'Pasta' => 8.00,
'Salad' => 6.00,
'Soda' => 2.00
};
Decimal totalBill = 0;
for (String item : order.keySet())
{
if (menu.containsKey(item))
{
totalBill += menu.get(item) * order.get(item);
}
}
return totalBill;
}
public static Decimal calculateBonuses(Map<String, Decimal> employees)
{
Decimal bonusAmount;
Map<String, Decimal> bonusMap = new Map<String, Decimal>();
for (String emp : employees.keyset())
{
Decimal SalesAmount = employees.get(emp);
Decimal bonusPercentage;
if (SalesAmount > 100000)
{
bonusPercentage = 0.20;
}else
{
bonusPercentage = 0.10;
}
bonusAmount = SalesAmount* bonusPercentage;
bonusMap.put(emp, bonusAmount);
}
system.debug(bonusMap);
return bonusAmount;
}
// LIST TO STORE PATIENTS WITH EMERGENCY LEVEL
/*List<String> patientList = new List<String>();
patientList.add('Ram-Normal');
patientList.add('Gopal-Critical');
patientList.add('Roshan-Severe');
patientList.add('Sham-Normal');
System.debug('Patients before sort: ' + patientList);
// LIST TO STORE EMERGENCY LEVELS
List<String> emergencyLevelList = new List<String>{
'Critical', 'Severe', 'Normal'
};
// LIST TO STORE SORTED PATIENTS WITH EMERGENCY LEVEL
List<String> sortedPatientList = new List<String>();
// ITERATE OVER EMERGENCY LEVELS
for(String emergencyLevel : emergencyLevelList) {
// ITERATE OVER PATIENTS
for(String patientData : patientList) {
// CHECK FOR SORTED EMERGENCY LEVELS
if(patientData.contains(emergencyLevel)) {
// STORE PATIENT NAME
sortedPatientList.add(patientData.split('-')[0]);
}
}
}
System.debug('Patients after sort: ' + sortedPatientList);*/
public static void PatientSorter(){
map<String, String> sortPatientsByPriority = new map<String, String>();
map<String, String> Patients = new map<String, String>();
Patients.put('Ram', ' Normal');
Patients.put('Gopal','Critical');
Patients.put('Roshan','Severe');
Patients.put('Sham','Normal');
system.debug('Patient before sort patient:' +Patients);
map<integer, String> emergencyLevel = new map<integer, String>();
emergencyLevel.put(1,'Severe');
emergencyLevel.put(2,'Critical');
emergencyLevel.put(3,'Normal');
for(String emergency:emergencyLevel.values()){
for(String patient:Patients.keyset()){
if(Patients.get(patient)==emergency)
{
sortPatientsByPriority.put(patient, emergency);
}
}
}system.debug(sortPatientsByPriority);
}
}