Description
Java Class Unit 2. There is 1 discussion, 1 assignment, and 1 test to be done by 20 December. I attached the instructions for Assignment and also attached the Instructions for how to submit the document. In the assignment on the “YourName” part please use this name: AhmetSahin To take the test you need to login my school account which I’ll be providing whenever you ready to take it. Please let me know if you have any questions
Unformatted Attachment Preview
ASSIGNMENT 2
Assignment 2 tests your knowledge of Decisions Structures (Chapter 4), repetition structures/Loops (Chapter 5) and Classes and
Objects in Java (Chapter 6) and should be solved using concepts learned in class so far (Chapters 1 to 6) and requirements bellow.
1. Design a class called YourNameMonth, replace YourName with your actual name) with the (exact) fields and methods1:
Field/Method
Description
Number
An integral field that holds the number of the month which is a value between 1 and 12 where
1
Number
Corresponding January
Name
YourNameMonth
YourNameMonth
YourNameMonth
YourNameMonth
getNumber
setNumber
getName
toString
equals
compareTo
2
February
3
4
March April
5
6
7
May June July
8
August
9
September
10
October
11
12
November December
A no-argument constructor that sets the Number field to 1
A constructor with one integral parameter representing the number of the month (1, 2, etc.) and sets the Number
field to that value. If a value less than 1 or larger that 12 is passed, the constructor should set Number to 1
A constructor with one string parameter representing the name of the month (“January”, “February”, etc.) that sets
the Number field to the corresponding number. If the value is invalid (less than 1 or larger than 12), should set
Number to 1. You should NOT add another field for the name of the month.
A copy constructor that copies the Number field value from another month object.
An integral method that returns the Number field value
A void method with an integral parameter that sets the Number field to that integral number
A String method that returns the name of the month corresponding to the Number field value
A string method that returns a string with this format: “Month is NUMBER” where NUMBER is the field Number
A Boolean method that accepts a YourNameMonth object Month2 as an argument and returns true if the data from
that object (its Number) is the same as the Number field of Month2 or false otherwise.
An integral method that accepts a Month object Month2as an argument and returns 0 if Number value from the class
is the same as the number from the Month2 object, -1 if it is smaller, and 1 if it is larger.
2. Design a driver class called YourNameAssignment2 (replace YourName with your actual name) in the same project as the
YourNameMonth. You will need to add the class Month to the project and add your code to the project class main method. The
program (code) should:
▪ Create three objects: Month1 using the first no-arg constructor, Month2 using the second constructor with 2 as an argument,
Month3 using the third constructor with “ October” as an argument, and Month4 using the fourth/copy constructor from Month3.
▪ Use the getNumber to get the month number from objects Month1, Month2, Month3, and Month4 and output the them.
▪ Use the getName to get the month name from objects Month1, Month2, Month3, and Month4 and output them.
▪ Use the setNumber to set the Month1 object value to 10.
▪ Use the toString to get the month string from objects Month1, Month2, Month3, and Month4 and output them.
▪ Use the equals method of Month1 to compare its value with Month2 value and output the result.
▪ Use the compareTo method of Month3 to compare its value with Month4 value and output the result.
3. Implement the classes in NetBeans IDE and JAVA: Create a JAVA project called YourNameAssignment2 (same name as the driver
class), add the class YourNameMonth to the YourNameAssignment2 project and add your code to the YourNameMonth class and
YourNameAssignmen2 project/driver class main method. Your program should be user-friendly and be welldocumented/commented (have comments for every line of code).
4. Create the screenshot document for your code and output: Create a Microsoft Word document from the YourNameAssignmentN.docx template and call it YourName-Assignment2.docx (replace YourName with your actual name) with your
screenshots of the NetBeans editor window showing the complete JAVA source code for both YourNameAssignment2 (Class 1) and
YourNamePet (Driver Class) classes and the complete output. If the entire class JAVA source code or the output does not fit in one
screenshot or the screenshots cannot be easily read, create multiple screenshots and add multiple screenshots to the screenshot
document. If your output is longer than a line and does not fit on one screen, Wrap Text in your output panel.
5. Submit your work: Submit YourName-Assignment2.docx on eCampus under the Assignment 2. Do not submit other types/formats
of files (e.g. no CLASS, PDF, JAVA, ZIP, RAR, etc.). Please take time after submitting to review the file and check it is correct and resubmit
it if there are any errors.
1
You are going to lose points for not documenting your code (commenting each line of code), for not naming the programs and files as requested,
not submitting the correct files, cheating, hardcoding the results, and using concepts we did not learn in class yet.
NAME: Your Name
ID: Your Student ID
ASSINGMENT Number
CLASS 1: Class1.java
Screenshots of the JAVA source code for CLASS1 in editor
CLASS 2: Class2.java
Screenshots of the JAVA source code for CLASS2 in editor.
CLASS 3: Class3.java
Screenshots of the JAVA source code for CLASS3 in editor.
DRIVER CLASS: DriverClass.java
Screenshots of the JAVA source code in editor
OUTPUT
Screenshots of the program output in editor
Purchase answer to see full
attachment