Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- class Employee
- {
- int empId;
- byte empAge;
- char empCategory;
- boolean isPermanent;
- short companyNo;
- public Employee(int empId, byte empAge, char empCategory, boolean isPermanent, short companyNo) {
- this.empId = empId;
- this.empAge = empAge;
- this.empCategory = empCategory;
- this.isPermanent = isPermanent;
- this.companyNo = companyNo;
- }
- public byte getEmpAge() {
- return empAge;
- }
- public void setEmpAge(byte empAge) {
- this.empAge = empAge;
- }
- public char getEmpCategory() {
- return empCategory;
- }
- public void setEmpCategory(char empCategory) {
- this.empCategory = empCategory;
- }
- public boolean isPermanent() {
- return isPermanent;
- }
- public void setPermanent(boolean permanent) {
- isPermanent = permanent;
- }
- public short getCompanyNo() {
- return companyNo;
- }
- public void setCompanyNo(short companyNo) {
- this.companyNo = companyNo;
- }
- public int getEmpId() {
- return empId;
- }
- public void setEmpId(int empId) {
- this.empId = empId;
- }
- @Override
- public String toString() {
- return "Employee{" +
- "empId=" + empId +
- ", empAge=" + empAge +
- ", empCategory=" + empCategory +
- ", isPermanent=" + isPermanent +
- ", companyNo=" + companyNo +
- '}';
- }
- }
- public class Main {
- public static void main(String[] args) {
- Employee[] employees = new Employee[5];
- Random random = new Random();
- for (int i = 0; i < employees.length; i++) {
- int empId = i + 1;
- byte empAge = (byte) (random.nextInt(50) + 20);
- char empCategory = (char) ('A' + i);
- boolean isPermanent = random.nextBoolean();
- short companyNo = (short) (random.nextInt(1000) + 1);
- employees[i] = new Employee(empId, empAge, empCategory, isPermanent, companyNo);
- }
- for (Employee employee : employees) {
- System.out.println(employee.toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement