提供高质量的essay代写,Paper代写,留学作业代写-天才代写

首頁 > > 詳細

Lab 4 Requirements

Lab 4 Requirements
Create a new Eclipse workspace named "Lab4_1234567890" on the desktop of your computer (replace 
1234567890 with your student ID number). For each question below, create a new project in that workspace. Call 
each project by its question number: "Question1", "Question2", etc. If you do not remember how to create a 
workspace or projects, read the "Introduction to Eclipse" document which is on iSpace. Answer all the questions below.
At the end of the lab, create a ZIP archive of the whole workspace folder. The resulting ZIP file must be called 
"Lab4_1234567890.zip" (replace 1234567890 with your student ID number). Upload the ZIP file on iSpace.
Question 1
Create a class Employee that contains the following things:
• a private integer ID number; • a constructor that takes as argument an ID number and uses this ID number to initialize the object's ID number; • a public method getID that takes zero argument and returns the ID number of the employee; • a public static method testEmployee that contains tests for your class.
Here is the corresponding UML diagram (remember that + means public and - means private):
+--------------------------+
| Employee | +--------------------------+
| - ID: int |
+--------------------------+
| + Employee(int ID) |
| + getID(): int |
| + testEmployee():void | +--------------------------+
The Employee class does not have a setID method because the ID number of an employee never changes.
How many tests should the testEmployee method contain?
Once you have written the Employee class, you can test it by adding the following code in a new class called Start in 
the same project:
public class Start {
public static void main(String[] args) {
Employee.testEmployee();
} }
This code calls the static testEmployee method of the Employee class, which should then run all your tests.
What is the problem if you make the ID instance variable public?
Question 2
Modify the constructor of the Employee class so that negative ID numbers or ID numbers larger than 10000 are not 
allowed when creating an Employee object. If the constructor is given a negative ID number or a ID number larger than 
10000 as the argument, then the constructor should use 0 for the ID number.
Modify your testEmployee method to test the new code. How many tests should the testEmployee method now 
contain?
Question 3
Add to your Employee class a string representing the position of the employee. The constructor for the class should 
now take the position of the employee as an extra argument. Also add to your class two methods getPosition and 
setPosition to get and change the position of an employee (an employee is allowed to change position).
Here is the corresponding UML diagram:
+------------------------------------+
| Employee | +------------------------------------+
| - ID: int |
| - position: String | +------------------------------------+
| + Employee(int ID, String position)|
| + getID(): int |
| + getPosition(): String |
| + setPosition(String position):void|
| + testEmployee(): void | +------------------------------------+
Note: we have not talked much about the String type in class yet. For now just use it like you use any other type (like 
int or float).
Do not forget to modify your testEmployee method to test the new code. In Java you can use == to compare 
constant strings.
Question 4
Add to your Employee class an integer representing the salary of the employee. The default salary when an employee 
is created is 3000. Also add to your class two methods getSalary and setSalary to get and change the salary of 
an employee.
Here is the corresponding UML diagram:
+------------------------------------+
| Employee | +------------------------------------+
| - ID: int |
| - position: String |
| - salary: int | +------------------------------------+
| + Employee(int ID, String position)|
| + getID(): int |
| + getPosition(): String |
| + setPosition(String position):void|
| + getSalary(): int |
| + setSalary(int salary): void |
| + testEmployee(): void | +------------------------------------+
Do not forget to modify your testEmployee method to test the new code.
Question 5
Add a new constructor to your Employee class that takes three arguments as input: an ID number, a position, and an 
initial salary. Using this second constructor it becomes possible to create Employee objects with an initial salary which 
is different from 3000.
Here is the corresponding UML diagram:
+------------------------------------------------+
| Employee | +------------------------------------------------+
| - ID: int |
| - position: String |
| - salary: int | +------------------------------------------------+
| + Employee(int ID, String position) |
| + Employee(int ID, String position, int salary)|
| + getID(): int |
| + getPosition(): String |
| + setPosition(String position):void |
| + getSalary(): int |
| + setSalary(int salary): void |
| + testEmployee(): void | +------------------------------------------------+
Do not forget to modify your testEmployee method to test the new code.
Question 6
Add to your Employee class a Boolean indicating whether the employee is currently playing the mobile phone during 
working hours. When an employee is created, the employee is working and not playing the mobile phone. Also add to 
your class three methods:
• one method isPlaying that returns a Boolean indicating whether the employee is currently playing the phone or 
not. • one method goToPlay that makes the employee stops working and starts to play the mobile phone. When an
employee starts to play the mobile phone, the salary of the employee decreases by 100 (if the current salary is less 
than 100, then the salary decreases to 0).
• one method goTOWork that makes the employee stop playing the mobile phone and start working. The salary of an
employee does not increase.
Here is the corresponding UML diagram:
+------------------------------------------------+
| Employee | +------------------------------------------------+
| - ID: int |
| - position: String |
| - salary: int |
| - playing: Boolean | +------------------------------------------------+
| + Employee(int ID, String position) |
| + Employee(int ID, String position, int salary)|
| + getID(): int |
| + getPosition(): String |
| + setPosition(String position):void |
| + getSalary(): int |
| + setSalary(int salary): void |
| + isPlaying():Boolean |
| + goToPlay():void |
| + goToWork():void |
| + testEmployee(): void | +------------------------------------------------+
Do not forget to modify your testEmployee method to test the new code.
聯系我們
  • QQ:1067665373
  • 郵箱:1067665373@qq.com
  • 工作時間:8:00-23:00
  • 微信:Essay_Cheery
熱點文章
程序代寫更多圖片

聯系我們 - QQ: 1067665373 微信:Essay_Cheery
? 2021 uk-essays.net
程序代寫網!

在線客服

售前咨詢
售后咨詢
微信號
Essay_Cheery
微信
全优代写 - 北美Essay代写,Report代写,留学生论文代写作业代写 北美顶级代写|加拿大美国论文作业代写服务-最靠谱价格低-CoursePass 论文代写等留学生作业代做服务,北美网课代修领导者AssignmentBack 北美最专业的线上写作专家:网课代修,网课代做,CS代写,程序代写 代码代写,CS编程代写,java代写北美最好的一站式学术代写服务机构 美国essay代写,作业代写,✔美国网课代上-最靠谱最低价 美国代写服务,作业代写,CS编程代写,java代写,python代写,c++/c代写 代写essay,作业代写,金融代写,business代写-留学生代写平台 北美代写,美国作业代写,网课代修,Assignment代写-100%原创 北美作业代写,【essay代写】,作业【assignment代写】,网课代上代考