العربية
فتح في Telegram

منشورimport java.util.*;

10 فبراير 2025
D
Deloitte | COGNIZANT | IBM | CAPGEMINI
import java.util.*; abstract class Employee { protected int id; protected String name; protected float baseSalary; public Employee(int id, String name, float baseSalary) { this.id = id; this.name = name; this.baseSalary = baseSalary; } public abstract float getSalary(); public void updateAttribute(String attribute, String value) { switch (attribute.toLowerCase()) { case "id": this.id = Integer.parseInt(value); System.out.println("Updated id to: " + this.id); break; case "name": this.name = value; System.out.println("Updated name to: " + this.name); break; case "base salary": this.baseSalary = Float.parseFloat(value); System.out.println("Updated base salary to: " + this.baseSalary); break; default: System.out.println("Invalid attribute for employee: " + attribute); } } public String retrieveAttribute(String attribute) { switch (attribute.toLowerCase()) { case "id": return String.valueOf(id); case "name": return name; case "base salary": return String.valueOf(baseSalary); default: return "Invalid attribute for employee: " + attribute; } } } class FullTimeEmployee extends Employee { private float bonus; public FullTimeEmployee(int id, String name, float baseSalary, float bonus) { super(id, name, baseSalary); this.bonus = bonus; } @Override public float getSalary() { return baseSalary + bonus; } @Override public void updateAttribute(String attribute, String value) { if (attribute.equalsIgnoreCase("bonus")) { this.bonus = Float.parseFloat(value); System.out.println("Updated bonus to: " + this.bonus); } else { super.updateAttribute(attribute, value); } } @Override public String retrieveAttribute(String attribute) { if (attribute.equalsIgnoreCase("bonus")) { return String.valueOf(bonus); } else { return super.retrieveAttribute(attribute); } } } class PartTimeEmployee extends Employee { private float hourlyRate; public PartTimeEmployee(int id, String name, float baseSalary, float hourlyRate) { super(id, name, baseSalary); this.hourlyRate = hourlyRate; } @Override public float getSalary() { return baseSalary * hourlyRate; } @Override public void updateAttribute(String attribute, String value) { if (attribute.equalsIgnoreCase("hourly rate")) { this.hourlyRate = Float.parseFloat(value); System.out.println("Updated hourly rate to: " + this.hourlyRate); } else { super.updateAttribute(attribute, value); } } @Override public String retrieveAttribute(String attribute) { if (attribute.equalsIgnoreCase("hourly rate")) { return String.valueOf(hourlyRate); } else { return super.retrieveAttribute(attribute); } } } class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); FullTimeEmployee fullTimeEmployee = new FullTimeEmployee(101, "Alice", 50000, 5000); PartTimeEmployee partTimeEmployee = new PartTimeEmployee(102, "Bob", 100, 40); while (true) { String command = scanner.nextLine().trim().toLowerCase(); if (command.equals("exit")) { break; } switch (command) { case "full time employee salary": System.out.println(fullTimeEmployee.getSalary()); break;
784 ·

بجوارها في الخلاصة

DDeloitte | COGNIZANT | IBM | CAPGEMINIIBM CIC ✅✅✅ Contact: @MLCODER2DDeloitte | COGNIZANT | IBM | CAPGEMINIL&T✅✅✅ Contact: @MLCODER2
هذه الرسالة
DDeloitte | COGNIZANT | IBM | CAPGEMINIcase "part time employee salary": System.out.println(partTimeEmployee.getSalary()); break; case "update full time employee":DDeloitte | COGNIZANT | IBM | CAPGEMINIComouter rental ✔️ #Offline_IBM_coding
DDeloitte | COGNIZANT | IBM | CAPGEMINIDeloitte | COGNIZANT | IBM | CAPGEMINI@python_java_Coding · قناة · التقنية
7 178مشتركون451متوسط وصول المنشور
خلاصة المجتمع فتح في Telegram

خلاصة عامة مفتوحة من فهرس البحث ChatCrawler — «Google لـ Telegram العام»؛ تُحدَّث كلما زحفنا إلى المجتمع. الأوقات بتوقيت UTC.

محتوى عام فقط، وAPI Telegram الرسمي. عن المشروع · الأسئلة الشائعة · حدود الفهرس · إزالة صفحة · الدليل · بحث · كيف نحسب