Comp/274 Week 2 - Inheritance and Polymorphism

In: English and Literature

Submitted By alexmicane4
Words 760
Pages 4
HELPIDO.COM

-------------------------------------------------------
Follow this link to get the tutorial

http://helpido.com/comp-274-week-2/
-------------------------------------------------------

COMP/274 Week 2 - Inheritance and Polymorphism
________________________________________

The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java.
The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior.
NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program!
The details of the three classes to be implemented are as follows:
A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE workerInfo method that returns a string containing the name, hourly pay rate, and federal tax rate. There must be a grossPay method that takes the number of hours worked as a parameter and calculates the gross pay (hours * payRate) and returns that as a double. There must be a taxWithheld method that takes a gross pay amount as a parameter and calculates the tax withheld (grossPay * taxRate) and returns that as a double.…...

Similar Documents

Comp 274 Week 2

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE workerInfo method that returns...

Words: 760 - Pages: 4

Comp 274 Week 3

...Follow this link http://helpido.com/comp-274-week-3/ -------------------------------------------------- COMP/274 Week 3 Programming Assignment ________________________________________ Week 3 Programming Assignment Create Java programs for the following two problems. 1. Write a Java application to display the following GUI. At this point you are only implementing the display. We are not ready to make the calculator actually do any calculations! This program has the following requirements: 1. The size of the calculator is 250 x 250 pixels. 2. The background and foreground color of the calculator buttons must alternate in a checker board pattern as shown above. You can choose any pair of colors for your foreground and background colors. 3. The buttons should have at least 5 pixels of space between them. 4. The text on the buttons should be SanSerif size 16 and be bold. 5. Your application should be implemented in a single class. The main method of the class does nothing more than create an object of the class. The constructor of the class creates and displays the GUI. The constructor may call other methods of the class if needed. 6. The class must inherit from JFrame as the following demonstrates: public myGUI extends JFrame { … } The extends keyword specifies inheritance. Inside the class you can directly access methods of the JFrame class without specifying an object due to inheritance. So when you want to add......

Words: 437 - Pages: 2

Comp 274 Week 2

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE workerInfo method that......

Words: 760 - Pages: 4

Comp 274 Week 2

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE workerInfo method that......

Words: 760 - Pages: 4

Comp/274 Week 2 - Inheritance and Polymorphism

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE workerInfo method that......

Words: 760 - Pages: 4

Comp274 Comp 274 Comp/274 Week 2

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP274 COMP 274 COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE......

Words: 763 - Pages: 4

Comp274 Comp 274 Comp/274 Week 2

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP274 COMP 274 COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE......

Words: 763 - Pages: 4

Comp 274 Comp274 Comp/274 Week 3

...Follow this link http://helpido.com/comp-274-week-3/ -------------------------------------------------- COMP 274 COMP274 COMP/274 Week 3 Programming Assignment ________________________________________ Week 3 Programming Assignment Create Java programs for the following two problems. 1. Write a Java application to display the following GUI. At this point you are only implementing the display. We are not ready to make the calculator actually do any calculations! This program has the following requirements: 1. The size of the calculator is 250 x 250 pixels. 2. The background and foreground color of the calculator buttons must alternate in a checker board pattern as shown above. You can choose any pair of colors for your foreground and background colors. 3. The buttons should have at least 5 pixels of space between them. 4. The text on the buttons should be SanSerif size 16 and be bold. 5. Your application should be implemented in a single class. The main method of the class does nothing more than create an object of the class. The constructor of the class creates and displays the GUI. The constructor may call other methods of the class if needed. 6. The class must inherit from JFrame as the following demonstrates: public myGUI extends JFrame { … } The extends keyword specifies inheritance. Inside the class you can directly access methods of the JFrame class without specifying an object due to inheritance. So when you want to add something......

Words: 440 - Pages: 2

Comp 274 Comp274 Comp/274 Week 3

...Follow this link http://helpido.com/comp-274-week-3/ -------------------------------------------------- COMP 274 COMP274 COMP/274 Week 3 Programming Assignment ________________________________________ Week 3 Programming Assignment Create Java programs for the following two problems. 1. Write a Java application to display the following GUI. At this point you are only implementing the display. We are not ready to make the calculator actually do any calculations! This program has the following requirements: 1. The size of the calculator is 250 x 250 pixels. 2. The background and foreground color of the calculator buttons must alternate in a checker board pattern as shown above. You can choose any pair of colors for your foreground and background colors. 3. The buttons should have at least 5 pixels of space between them. 4. The text on the buttons should be SanSerif size 16 and be bold. 5. Your application should be implemented in a single class. The main method of the class does nothing more than create an object of the class. The constructor of the class creates and displays the GUI. The constructor may call other methods of the class if needed. 6. The class must inherit from JFrame as the following demonstrates: public myGUI extends JFrame { … } The extends keyword specifies inheritance. Inside the class you can directly access methods of the JFrame class without specifying an object due to inheritance. So when you want to add something......

Words: 440 - Pages: 2

Comp274 Comp/274 Comp 274 Week 4

...------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-4-3/ ------------------------------------------------------- COMP 274 - Week 4 Programming Assignment ________________________________________ Write a Java GUI application to allow you to experiment with colors and fonts. The general appearance of you GUI should be something similar to the following: Your program must meet the following requirements: 1. Do not use any of the GUI editing capabilities of Eclipse for this assignment. Do all the GUI layout work based on what you have learned in class in the last 2 weeks. 2. You can use either inheritance or composition to get a JFrame into your application. 3. All member variables must be private. 4. The GUI and event handling setup must be done in the constructor of your GUI class or in privatemethods called from the constructor. Hint: it would seem logical to have a private method to build the top, left, and bottom panels. 5. The main text field (the red one above) will be used to show the results from the selection of font size, bold and italic selection, and foreground and background color selection. 6. The display must have a label and JTextField where the user inputs a font size value and which must appear in the upper part of the frame as shown above. 7. There must also be 2 check boxes that will control whether the font has bold and/or......

Words: 801 - Pages: 4

Comp274 Comp/274 Comp 274 Week 4

...------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-4-3/ ------------------------------------------------------- COMP 274 - Week 4 Programming Assignment ________________________________________ Write a Java GUI application to allow you to experiment with colors and fonts. The general appearance of you GUI should be something similar to the following: Your program must meet the following requirements: 1. Do not use any of the GUI editing capabilities of Eclipse for this assignment. Do all the GUI layout work based on what you have learned in class in the last 2 weeks. 2. You can use either inheritance or composition to get a JFrame into your application. 3. All member variables must be private. 4. The GUI and event handling setup must be done in the constructor of your GUI class or in privatemethods called from the constructor. Hint: it would seem logical to have a private method to build the top, left, and bottom panels. 5. The main text field (the red one above) will be used to show the results from the selection of font size, bold and italic selection, and foreground and background color selection. 6. The display must have a label and JTextField where the user inputs a font size value and which must appear in the upper part of the frame as shown above. 7. There must also be 2 check boxes that will control whether the font has bold and/or......

Words: 801 - Pages: 4

Comp274 Comp 274 Comp/274 Week 2

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP274 COMP 274 COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE......

Words: 763 - Pages: 4

Comp274 Comp 274 Comp/274 Week 2

...HELPIDO.COM ------------------------------------------------------- Follow this link to get the tutorial http://helpido.com/comp-274-week-2/ ------------------------------------------------------- COMP274 COMP 274 COMP/274 Week 2 - Inheritance and Polymorphism ________________________________________ The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java. The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior. NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program! The details of the three classes to be implemented are as follows: A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE......

Words: 763 - Pages: 4

Comp 274 Comp274 Comp/274 Week 3

...get the tutorial http://helpido.com/comp-274-week-3/ -------------------------------------------------- COMP 274 COMP274 COMP/274 Week 3 Programming Assignment ________________________________________ Week 3 Programming Assignment Create Java programs for the following two problems. 1. Write a Java application to display the following GUI. At this point you are only implementing the display. We are not ready to make the calculator actually do any calculations! This program has the following requirements: 1. The size of the calculator is 250 x 250 pixels. 2. The background and foreground color of the calculator buttons must alternate in a checker board pattern as shown above. You can choose any pair of colors for your foreground and background colors. 3. The buttons should have at least 5 pixels of space between them. 4. The text on the buttons should be SanSerif size 16 and be bold. 5. Your application should be implemented in a single class. The main method of the class does nothing more than create an object of the class. The constructor of the class creates and displays the GUI. The constructor may call other methods of the class if needed. 6. The class must inherit from JFrame as the following demonstrates: public myGUI extends JFrame { … } The extends keyword specifies inheritance. Inside the class you can directly access methods of the JFrame class without specifying an object due to inheritance. So when you want to add something......

Words: 444 - Pages: 2

Comp 274 Comp274 Comp/274 Week 3

...get the tutorial http://helpido.com/comp-274-week-3/ -------------------------------------------------- COMP 274 COMP274 COMP/274 Week 3 Programming Assignment ________________________________________ Week 3 Programming Assignment Create Java programs for the following two problems. 1. Write a Java application to display the following GUI. At this point you are only implementing the display. We are not ready to make the calculator actually do any calculations! This program has the following requirements: 1. The size of the calculator is 250 x 250 pixels. 2. The background and foreground color of the calculator buttons must alternate in a checker board pattern as shown above. You can choose any pair of colors for your foreground and background colors. 3. The buttons should have at least 5 pixels of space between them. 4. The text on the buttons should be SanSerif size 16 and be bold. 5. Your application should be implemented in a single class. The main method of the class does nothing more than create an object of the class. The constructor of the class creates and displays the GUI. The constructor may call other methods of the class if needed. 6. The class must inherit from JFrame as the following demonstrates: public myGUI extends JFrame { … } The extends keyword specifies inheritance. Inside the class you can directly access methods of the JFrame class without specifying an object due to inheritance. So when you want to add something......

Words: 444 - Pages: 2