Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

This project focuses on demonstrating your understanding of classes and objects. 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. The project requirements include:

Design and implement a stringed musical instrument violin class using the following guidelines:

Data fields for violin should include number of strings, an array of string names representing string names (e.g. E,A,D,G), and boolean fields to determine if the instrument is tuned, and if the instrument is currently playing. You are welcome to add additional data fields if you like.

A constructor method that set the tuned and currently playing fields to false.

Other methods

1) to tune the instrument

2) to start the instrument playing

3) to stop the instrument from playing.

4) return number of strings

5) return an array of string names representing string names (e.g. E,A,D,G)

Create a UML class diagram using a diagram tool (e.g. PPT, Visio) of your choice. Prepare the diagrams and place them in a word document along with a brief description of each of your classes.

Create Java classes for your instruments. Be sure that your code matches your design specifications and some minimal functionality is included. For example, if you called the violin.play() method, you should at least print that the violin is playing. Similar functionality should be supplied when you stop playing, tune or call any of your methods. For example:

public void playviolin() {

System.out.println("The violin is now playing.");

}

Write the output from your Instrument class methods to a text file that a user entered from the command line arguments (e.g. java violinOutput.txt). This allows your program to accept filenames from the user via a command line argument.

Finally, create a Java test class that simulates using your instrument class. In your test class be you should at a minimum: a) Construct 10 instances of your instrument, b) tune your instruments, c) Start playing your instrument, d) Call your unique method such as write string numbers and names, and e) Stop playing your instruments. (Hint: Arrays and Loops will make your job easier and result in more efficient code!)

Your programs should compile and run without errors.

Be sure

import java.io.*;

public class Test{

public static void main(String[] args) {

String outputFile = "";

if (0 < args.length) {

outputFile = args[0];

System.out.println("This program will write output to this file: " + outputFile + "\n");

try {

File file = new File(outputFile);

PrintWriter output = new PrintWriter(outputFile);

output.println("hello"); //to check if ir prints anything

Violin[] simpleViolin = new Violin[5];

//Create 5 violin objects

for (int i = 0; i < simpleViolin.length; i++){

simpleViolin = new Violin();

}

output.println("\nLet's tune " + Violin.getNumberOfViolins() + " violins.");

for(int i = 0; i < simpleViolin.length; i++){

output.print(i + 1);

simpleViolin.tuneOn();

}

output.println("\nNow let's start playing " + Violin.getNumberOfViolins() + " violins.");

for(int i = 0; i < simpleViolin.length; i++){

output.print(i + 1);

simpleViolin.startPlaying();

}

output.println("\nIt looks like " + Violin.getNumberOfViolins() + " violins have untuned.");

for(int i = 0; i < simpleViolin.length; i++){

output.print(i + 1);

simpleViolin.tuneOff();

}

output.println("\nThis music is terrible! Let's stop it!");

for(int i = 0; i < simpleViolin.length; i++){

output.print(i + 1);

simpleViolin.stopPlaying();

}

output.close();

}

catch (IOException io){

System.out.println("Sorry that file is not found " + io);

}

}//end if

}//end main

}//end Test

class Violin{

private final int numberOfStrings = 4;

private final char[] stringNames = {'E', 'A', 'D', 'G'};

private boolean isTuned = false;

private boolean isPlaying = false;

private static int numberOfViolins = 0;

private PrintWriter output;

public Violin(){

numberOfViolins++;

}

public void startPlaying() {

isPlaying = true;

System.out.println(" violin is now playing.");

}

public void stopPlaying() {

isPlaying = false;

System.out.println(" violin has stopped playing.");

}

public void tuneOn() {

isTuned = true;

System.out.println(" violin is now tuned.");

}

public void tuneOff() {

isTuned = false;

System.out.println(" violin is untuned.");

}

static int getNumberOfViolins(){

return numberOfViolins;

}

}

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91357305
  • Price:- $50

Guranteed 36 Hours Delivery, In Price:- $50

Have any Question?


Related Questions in Programming Language

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As