413 employee class create a class called employee

This preview shows page 9 - 11 out of 11 pages.

4.13 (Employee Class) Create a class called Employee that includes three pieces ofinformation as either instance variables or automatic properties—a first name (typestring), a last name (type string) and a monthly salary (decimal). Your class should have aconstructor that initializes the three values. Provide a property with a get and set accessorfor any instance variables. If the monthly salary is negative, the set accessor should leavethe instance variable unchanged. Write a test app named EmployeeTest that demonstratesclass Employee’s capabilities. Create two Employee objects and display each object’s yearlysalary. Then give each Employee a 10% raise and display each Employee’s yearly salaryagain.
12 * employee1.MonthlySalary );. . .}4.14 (Date Class) Create a class called Date that includes three pieces of information asautomatic properties—a month (type int), a day (type int) and a year (type int). Your classshould have a constructor that initializes the three automatic properties and assumes thatthe values provided are correct. Provide a method DisplayDate that displays the month,day and year separated by forward slashes (/). Write a test app named DateTest thatdemonstrates class Date’s capabilities.public class Date {// fieldsprivate int month;private int day;private int year;// constructorpublic Date(int month, int day, int year){this.month = month;this.day = day;this.year = year;}public void setMonth(int month){this.month = month;}public void setDay(int day){this.day = day;}public void setYear(int year){this.year = year;
}public int getMonth(){return month;}public int getDay(){return day;}public int getYear(){return year;}public String displayDate()return month + "/" + day + "/" + "/" + year;}}
End of preview. Want to read all 11 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Winter
Professor
N/A
Tags
Object Oriented Programming, instance variable

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture