completed assignment

This commit is contained in:
2025-04-02 17:50:49 +05:30
parent 35e7485001
commit 72f2541f58
32 changed files with 531 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
public class Assigmnt2 {
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>

View File

@@ -0,0 +1,166 @@
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);
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>

View File

@@ -0,0 +1,93 @@
public class training {
public static void abc(){
list<string> cities= new list<string>();
cities.add('Delhi');
cities.add(0,'Mumbai');
cities.add('Kolkata');
System.debug('cities'+ cities);
list<string> fruits= new list<string>();
fruits.add('Apple');
fruits.add('Pears');
fruits.add('Orange');
fruits.addAll(cities);
System.debug(fruits);
//fruits.clear();
System.debug(fruits);
system.debug(cities.contains('Kolkata'));
system.debug(fruits.remove(2));
system.debug(cities.size());
}
public static void operators(){
integer a= 55, b= 39, c;
c= a+b;
system.debug(c);
Decimal h= 7.8,j=6, i;
i= h*j;
system.debug(i);
Decimal o= 1.9,u= 4.4, r;
r= o-u;
System.debug(r);
Decimal s= 9.0,t=3,n;
n= s/t;
System.debug(n);
integer w= 78,q= 7, d;
d= w/q;
System.debug(d);
}
public static void method3(){
set <integer> num= new set<integer>();
num.add(10);
num.add(15);
num.add(20);
num.add(25);
num.add(26);
system.debug(num);
system.debug(num.contains(20));
set<string> cities= new set<string>();
cities.add('Delhi');
cities.add('Mumbai');
cities.add('Kolkata');
cities.add('Bhubaneswar');
system.debug(cities);
list<string> cities1= new list<string>();
cities1.add('Guwahati');
cities1.add('Hyderabad');
system.debug(cities1);
cities.addAll(cities1);
system.debug(cities);
//cities.clear();
set <string> cities2= cities.clone();
system.debug(cities2);
system.debug(cities.size());
}
public static void method4(){
map <integer,string> flowers= new map<integer,string>();
flowers.put(1,'Lotus');
flowers.put(2,'Lily');
flowers.put(3,'Hibiscus');
flowers.put(4,'Rose');
flowers.put(5,'Jasmine');
system.debug(flowers);
//flowers.clear();
system.debug(flowers);
system.debug(flowers.containskey(9));
map <integer,string> colors= new map<integer,string>();
colors.put(6,'Blue');
colors.put(7,'Red');
colors.put(8,'Yellow');
colors.put(9,'White');
flowers.putall(colors);
system.debug(flowers);
map <integer,string> flowers2= new map<integer,string>();
colors.remove(7);
system.debug(colors);
system.debug(colors.size());
system.debug(flowers.size());
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<status>Active</status>
</ApexClass>