Jacob,
Your program does not run because it does not have a dedicated class. You cannot use PRJ3RennelsJ as the class for the instruments. You need to create a separate class. Please rework this assignment and resubmit. You have until Saturday evening to submit a new program that is consistent with OO. You will get a grade today with 0 for Project 3, but that will change when you turn in a program that is workable in OO.
CMIS 141: Java Programming
Project 3
This project focuses on demonstrating your understanding of classes and objects. In addition you will demonstrate generating a text file. Before attempting this project, be sure you have completed all of the reading assignments listed in the syllabus to date, participated in the weekly conferences, and thoroughly understand the examples throughout the chapters.
There are several ways of executing this program. One way is to execute the program on a “command line” as referenced in the readings. This assignment is not being executed in that manner; it is being processed in the same way all the other assignments were completed in this class.
This program gives a user the opportunity to “play” a musical instrument. Since there are ten instances of a musical instrument, you can play several of the musical instruments (instances) before ending the program. It is expected that there will be at least two instances appearing in you output text file.
Project 3 (25 percent):
1. Create a Java Application Project named PRJ3[Last Name][First Initial]. As an example, if your name was Xavier Smith, then the project would be named PRJ3SmithX. Even though many examples show the class as a separate file from the main program, this assignment will consist of a single program file and no additional files for class.
2. Review the requirements for the program (3 a. – 3 d.) then generate a test plan in a document named PRJ3SmithXTestPlan using the Test Plan Explanation with Rubric document listed in Week 1 Activities.
3. Once you are in the IDE with the tabbed PRJ3SmithX.java in the Source window, begin developing the following program:
a. Identifiers for your instrument should include:
1) An array for a string instrument with at least ten instances. [The values in the various cells can be the names of various types of string instruments, e.g., violin, guitar, 12-string guitar, etc. However, it is expected that the array will either have an individual number or letter, or a combination number-letter if it is designated as an inventory item.]
2) An array for the strings of the string instrument, for example, a guitar normally uses E, A, D, G, B, and E for determining a chord. [Other string instruments have different string configurations, e.g. violin uses G, D, A, and E. This element can be researched for a different instrument. It is assumed that because of the complexity of this assignment, the program will probably use a single instrument with a single set of strings.]
3) A Boolean field to determine if the instrument is tuned.
4) A Boolean field to determine if the instrument is currently playing.
5) A volume that allows ten increments of sound (1-10) while the instrument is playing.
6) A register for an instance of the instrument that allows five levels (1-5).
7) A tone control for an instance of the instrument that allows five modes (1-5).
8) A pickup configuration that allows three choices (bridge, neck, or both).
9) A chord array based on the size determined by the array of strings mentioned (See 2) above). [For the purposes of this assignment, a chord is a set of two or more strings of an instrument sounded at the same time.]
b. A constructor method that initializes the variables in the class.
c. Methods include:
1) An interactive element that requests from the user the selection of one of the ten instances of the string instrument array to change. [This method is in main. There should probably be some list to choose from.]
2) An interactive process that goes through a set of sequential questions (no menu) based on all the attributes of an instrument instance, changes the values of some or all of the attributes for an instance of the string instrument, for example, from not playing to start playing an instance of guitarFour [the selected instance from the ten choices]:
Do you want to play guitarFour? (Y/N)
[The user would then enter a Y, y, N, n after this question and the program would assign that value to the appropriate identifier.]
3) Among the questions within c. 2., there is a method that selects a specific chord on the string instrument instance for playing. [Note: it is best to have individual requests for each of the strings that will be part of a specific chord, so an instrument with four strings would have four questions with a yes or no answer for including the string in the chord. The resulting display would show on a single line only the strings that were selected. So using a violin with G, D, A, and E, if only D and E had a yes response, then the output would be D E.]
4) Display in the Output window all processing as the program runs about an instance of the string instrument, e. g, all the questions and answers in the interactive section for the attributes of the string instrument instance.
5) Output to a text file the various attributes of the instance of the instrument – do not include any of the questions from c. 2. above – with two different sets:
a. the initial state of the string instrument instance [added at the beginning of the method]
b. the state after processing that instance [added after all the questions are answered]
The following is an example of coding that might be used with this requirement.
FileWriter instrumentFile;
instrumentFile = new FileWriter("instrumentConfig.txt", true);
PrintWriter Configuration = new PrintWriter(instrumentFile);
Configuration.print("Instrument status follows:\n");
6) If more than one instance is selected, then each instance appears in the text file with its own set of initial and final states.
7) The text file should default to the Project folder under CMIS141.
d. The program structure (see Skeleton at end of this document) should have
1) The main function:
a) Declare an array of ten instances for the instrument.
b) Declare the necessary elements for a text file.
c) Declare additional variables as necessary.
d) A looping structure that
• Selects an instance of the string instrument.
• Displays the initial state of that instance in the Output window and in the text file.
• Once a specific instance is select, allows the user to change some or all of the values of the attributes of that instance of the instrument displaying the whole process in the Output window.
e) At the end the looping structure, display the modified instance of the instrument in the Output window and in the text file.
f) Prompt the user to end the loop or continue to modifying another instance of the instrument.
2) The class section:
a) Declare all appropriate identifiers.
b) Declare an array for the strings of the instrument.
c) Initialize the variables in the constructor.
d) An interactive method to change values the attributes of an instance of the instrument.
e) An output method to display information in the Output window called at the loop.
f) An output method to display information to the text file called at the end of the loop.
g) Methods to change the values of various class identifiers, including making a chord.
When changing a value that is declared inside of the class, the method does not require passing the value to that method. There is also no need for a return line, so the method should be void. [Review the examples at the end of Homework 4.] For example, if you called the guitar.play() method, the method would look like:
public void play() {
isPlaying = true;
System.out.println("The guitar is now playing.");
} // end play ()
4. Write the output from your instrument class methods to a text file, e.g. PRJ3SmithXFile.txt.
5. When the assignment works correctly for all parts, capture images of the results from the Output window for each of the test plan sets of data – the program will have to run for each of the sets – and paste each of them after the test plan prepared in Item 2. above into a file PRJ3SmithXTestPlan.
6. Once you complete the Project 3 program attach the PRJ3SmithX.java file from the appropriate folder under the CMIS141 folder as well as the PRJ3SmithXTestPlan file to the appropriate Assignment element.
7. Based on the coding of the program, create a UML class diagram using a diagram tool using either MS PowerPoint or Visio. Prepare the diagrams and place them in a MS Word document along with a brief description of each of your classes. For help with UML:
http://www.smartdraw.com/resources/tutorials/uml-diagrams/
another reference that can be helpful is
http://www.lucidchart.com/
and a third reference [perhaps best place to start]
http://en.wikipedia.org/wiki/Unified_Modeling_Language
8. The UML diagram document is named PRJ3SmithXUML. Submit this document with the two identified in 6 above to the appropriate Assignment element.
Reference the concept of objects:
http://docs.oracle.com/javase/tutorial/java/concepts/object.html
Design Rubric for Project 3 (20 percent):
• Coding is properly ordered with declarations for the identifiers in main and class, inside a while loop select on instance off menu/list, write to text initial attributes, solicit responses from user, display summary results, write to text modified/final attributes, repeat until user ends loop, and a final message before ending the program
• Declare an array of ten instances for an instrument [String or integer data type]
• Declare the necessary elements for a text file
• Use of Boolean data type for binary responses
• Declare additional variables as necessary for the instrument attributes
• Calls to appropriate methods
In the class:
• Declare all appropriate identifiers
• Declare an array for the strings of the instrument [a chord array]
• Initialize the variables in the constructor
• Interactive method to change values the attributes of an instance of the instrument
• Output method to display information in the Output window called in the loop
• Output method to display information to the text file called at the beginning and the end of the loop
• Methods to change the values of various class identifiers, including making a chord
Within a loop:
• A menu or listing that allows user to select an instrument instance from the ten choices
• An interrogatory section with uses selecting various elements for the attributes of the instrument instance with user-friendly prompts
• Displays result of all the attribute results from the interrogatory section
• Displays result of user-selected chord on screen
• Prompt for continuation of loop to select and modify additional instrument instances
In the text file:
• The initial state for all the attributes of a selected instance written vertically
• The final state for all the attributes of a selected instance written vertically
• Additional sets of initial/final states for different selected instances
• There is no redundant coding
• The appropriate libraries are imported
• The Java class properly structured
• A properly developed UML diagram
Functionality Rubric for Project 3 (40 percent):
• Correctly declared all identifiers
• Appropriate loop continues until test is false
• All requested values are properly entered
• Correctly constructed a method using a call with parameters to display the appropriate information
• Interactive request for specific instance from the ten-element array
• Interactive section requesting user to select from a sequential list attributes of the instrument should be changed – all or some of the attributes
• Interactive request for a specific chord on the instrument
• Displaying results of all elements of the program including
• Prompt to continue modifying another instance or ending the program
• Output window displays menu/list
• Output window displays questions for modification of various elements of the attributes, including the chord
• Text file vertically written initial state of an instrument instance
• Text file vertically written modified/final state of an instrument instance
• Repeated sets of initial/final state for additional instrument instances
• Used the requested text
• Coded the requested blank lines
• Coding was implemented correctly
• All requested elements of the program were implemented
Documentation Rubric for Project 3 (20 percent):
• Refer to Documentation Explanation with Rubric in Week 1 Activities.
Test Plan Rubric for Project 3 (20 percent):
• Refer to Test Plan Explanation with Rubric in Week 1 Activities.
1. The skeleton:
package prj3programmerame;
/*
* @author Programmer Name
*/
import java.* ; section
public class PRJ3ProgrammerName {
public static void main(String[]args) {
- Declarations
- Loop to select instance and interactively change instances of the instrument and output initial state and final state of an instance
}// end main
}//end PRJ3ProgrammerName class
public class [InstrumentName] {
[Variable declarations]
//constructor for class
public [InstrumentName] () {
[Variables Initialized]
}//[InstrumentName] constructor
public void [A Method Name] () {
[Code for the method]
}//end [A Method Name]
}//end [InsturmentName} class
Campbell Ritchie wrote:Please review your code style. Your code is difficult to read because you have crammed it all together.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote: You have used that dreadful, error‑prone construct == true.
There are worse crimes than burning books. One of them is not reading them. Ray Bradbury
There are worse crimes than burning books. One of them is not reading them. Ray Bradbury
Jake Rennels wrote:In my latest rewrite of the code, I'm trying a different approach, hoping that this latest semi-educated guess reflects OOP. As much as I've read online and in my text, it just doesn't seem to "click" with me.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Jake Rennels wrote:I *think* I had my eureka moment. Aside from the fact that the getInstrumentAttributes method is not written yet, does this version of my code demonstrate OOP?
I'm also aware that my code on lines 28 and 29 are not supported in versions prior to Java 7. What happens if a user with an earlier version of Java attempts to run this code?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Jake Rennels wrote:Does that sound about right?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Jake Rennels wrote:I think I have it. How does this look? Any closer to OOP?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Jake Rennels wrote:Winston, Thanks again for all your help.
The class is finished one way or another, but I feel that one week to discover what OO and make that jump from procedural followed by one week to complete an OOP was certainly insufficient for me.
Depending on the grade, I could have as much as a B, as it is worth 25% of my grade for the class.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|