DCIT 201 Assignment
DCIT 201 Assignment
class CommissionEmployee {
// validating constructor
this.firstName = firstName;
this.lastName = lastName;
this.socialSecurityNumber = socialSecurityNumber;
setGrossSales(grossSales);
setCommissionRate(commissionRate);
return firstName;
this.firstName = firstName;
this.lastName = lastName;
return socialSecurityNumber;
this.socialSecurityNumber = socialSecurityNumber;
return grossSales;
this.grossSales = grossSales;
return commissionRate;
}
this.commissionRate = commissionRate;
@Override
try {
// Creating an employee
// Updating values
employee.setGrossSales(7000.0);
employee.setCommissionRate(0.15);
// Display earnings
} catch (IllegalArgumentException e) {
try {
} catch (IllegalArgumentException e) {
Inheritance
Question five(5) code
import java.util.ArrayList;
import java.util.List;
this.employeeId = employeeId;
this.name = name;
super(employeeId, name);
this.specialty = specialty;
@Override
super(employeeId, name);
this.assignedSection = assignedSection;
@Override
class RestaurantManagementSystem {
employee.performDuty();
employees.add(chef);
employees.add(waiter);
// Assigning duties
system.assignDuty(emp);
Polymorphism
Question One(1)
// Constructor
this.firstName = firstName;
this.lastName = lastName;
this.socialSecurityNumber = socialSecurityNumber;
setGrossSales(grossSales);
setCommissionRate(commissionRate);
return grossSales;
if (grossSales < 0) {
this.grossSales = grossSales;
return commissionRate;
this.commissionRate = commissionRate;
// Earnings method
// Constructor
setBaseSalary(baseSalary);
return baseSalary;
if (baseSalary <= 0) {
this.baseSalary = baseSalary;
@Override
@Override
}
public class Main {
try {
System.out.println(employee);
employee.setBaseSalary(3500);
employee.setGrossSales(12000);
employee.setCommissionRate(0.12);
System.out.println(employee);
try {
try {
} catch (IllegalArgumentException e) {
try {
} catch (IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
Abstraction
Question (5)
import java.util.ArrayList;
import java.util.Scanner;
interface Department {
class Hostel {
this.hostelName = name;
this.hostelLocation = location;
this.numberOfRooms = rooms;
this.studentName = scanner.nextLine();
this.regdNo = scanner.nextLine();
this.electiveSubject = scanner.nextLine();
this.avgMarks = scanner.nextDouble();
this.deptName = scanner.nextLine();
this.deptHead = scanner.nextLine();
}
// printing student details
printDepartmentDetails();
printHostelDetails();
@Override
class UniversityDriverMenu {
student.getStudentDetails();
studentList.add(student);
if (student.getRegdNo().equals(regdNo)) {
student.setHostelDetails(hostelName, hostelLocation,
numberOfRooms);
return;
if (student.getRegdNo().equals(regdNo)) {
student.printStudentDetails();
return;
while (true) {
System.out.println("4. Exit");
switch (choice) {
case 1:
admitNewStudent();
break;
case 2:
migrateStudent();
break;
case 3:
displayStudentDetails();
break;
case 4:
return;
default:
driver.displayMenu();