Question

Lab 2 (ADTs) 1) LockADT – Show the interface and all abstract methods LockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, s...

Lab 2 (ADTs)
1)

LockADT – Show the interface and all abstract methods


LockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, setZ, alter (change the lock’s combination to the numbers passed) turn (use for loops to show the dial turning), close (locks the lock), attempt (tries to unlock the lock – calls turn( ), inquire (locked or unlocked), current (returns the number the dial is pointing to), toString
LockClientDemoClass – You should have a Lock object instantiated and a menu method that displays:
1: set lock combination  
2: close lock   
3: check status  
4: attempt to open lock
5: check what the dial is currently pointing at
6: exit the program

Example of turning the lock:
First number (17):  0 39 38 37 … 0 39 38 …17
Second number (26): 17 18 19 ... 38 39 0 1 2 … 17 18 19 20 21 22 23 24 25 26
Third number (9): 26 25 24 23 …. 12 11 10 9 (go directly to the number)

Demonstrate all behaviors (actions, methods) of the lock.

NoteADT - Show the interface and all abstract methods


NoteDataStructureClass - Show the following methods: default constructor, overloaded constructor, copy constructor, setValue (calls other methods: setStrValue, setKeyColor, setFrequency), setLength (calls setStrLength), setFrequency (should be double value- cast)setKeyColor, getValue, getLength, getKeyColor, getFrequency, toString.
NoteClientDemoClass –Instantiate two Note objects using the overloaded constructor and two Note objects using the default constructor.
A sample output for 1 Note object might appear like:
F#
Length: Eighth note
Value: -3
Black key (sharp)
369.995672 Hz

2)

Specify, design, and implement a class that can be used in a program that simulates a combination lock. The lock has a circular knob with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we will call x, y, and z.


In order to open the lock, you must turn the knob clockwise at least one entire  revolution, stopping with x at the top; then you turn the knob counterclockwise, stopping the “second” time that y appears at the top; finally, you turn the knob clockwise again, stopping the next time that z appears at the top. At this point, you may open the lock.
Your “Lock” class should have a constructor that initializes the 3-number combination (use 0, 0, 0 for default arguments in the default constructor).
Also, provide the following methods:

To alter the lock’s combination to a new 3-number combination


To turn the knob in a given direction until a specified number appears at the top. (You also must show all of the numbers in the output as the lock is being turned – could use a for loop)


To close the lock


To attempt to open the lock


To inquire about the status of the lock (open or shut)


To tell what number is currently at the top


Write a complete Java program that uses all of the above methods in the output.

Specify, design, and implement a “Note” class that can be used to hold information about a musical note.  A programmer should be able to set and retrieve the length of the note and the value of the note.


The length of a note may be a sixteenth note, eighth note, quarter note, half note, or whole note.
A value is specified by indicating how far the note lies above or below the “A” note that orchestras use in tuning. In counting “how far,” you should include both the white and black notes on a piano.
For example, the note (value) numbers for the octave beginning at middle C are shown as integers here:
     -8   -6       -3 -1 1
 
    -9 -7   -5 -4 -2    0 2
Write a complete Java program.

The default constructor should set a note to a middle C quarter note.


Include methods to set a note to a specified length and value.


Write methods to retrieve information about a note, including methods to tell you:

The letter of the note (A, B, C, …, G)


Whether the note is a natural (white key) or a sharp (black key) on the piano


The frequency of a note in hertz.


     In order to calculate the frequency, use the formula:  440 * 2n/12, where n is the note number.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

floot odd Cloot, floak) lang a, b, x end arg Sm

Add a comment
Know the answer?
Add Answer to:
Lab 2 (ADTs) 1) LockADT – Show the interface and all abstract methods LockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, s...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • LockADT

    1.   LockADT – Show the interface and all abstract methodsLockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, setZ, alter (change the lock’s combination to the numbers passed) turn (use for loops to show the dial turning), close (locks the lock), attempt (tries to unlock the lock – calls turn( ), inquire (locked or unlocked), current (returns the number the dial is pointing to), toStringLockClientDemoClass – You should have a Lock object instantiated and a...

  • it's a JAVA program. Share Edit & Create aanmethod that tests all three overloaded methods. Save...

    it's a JAVA program. Share Edit & Create aanmethod that tests all three overloaded methods. Save the application as Billing.java. a. Create a FitnessTracker class that includes data fields for a fitness activity the number of minutes spent participating, and the date. The class includes methods to get each field. In addition, create a default constructor that automatically sets the activity to running, the minutes to 0, and the date to January 1 of the current year. Save the file...

  • Declare a class ComboLock that works like the combination lock in a school or gym locker.....

    Declare a class ComboLock that works like the combination lock in a school or gym locker.. The lock is constructed with a combination dial numbers between 0 and 39. The constructor sets the three "secret" numbers and the current position to 0. The reset method resets the dial so that it points to 0. The turnLeft and turnRight methods turn the dial by a given number of ticks to the left or right. The open method attempts to open the...

  • Java Help, Will definitely give a thumbs up if it works. Declare a class ComboLock that...

    Java Help, Will definitely give a thumbs up if it works. Declare a class ComboLock that works like the combination lock in a gym locker (Consult the API provided to look for the methods needed). The locker is constructed with a combination - three numbers between 0 and 39. The reset method resets the dial so that it points to 0. The turnLeft and turnRight methods turn the dial by a given number of ticks to the left or right....

  • JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class....

    JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

  • IN JAVA LANGUAGE: For this lab you are required for implement the following methods: 1. public...

    IN JAVA LANGUAGE: For this lab you are required for implement the following methods: 1. public QuadraticProbingHashTable( int size ): As the signature of this method suggests, this is a constructor for this class. This constructor will initialize status of an object from this class based on the input parameter (i.e., size). So, this function will create the array HashTable with the specified size and initialize all of its elements to be null. 2. public int hash(int value, int tableSize...

  • ise 1. Create a new project named lab6 1. You will be implementing an IceCream class. For the class attributes, let&#39...

    ise 1. Create a new project named lab6 1. You will be implementing an IceCream class. For the class attributes, let's stick to flavor, number ofscoops, and price (in cents). Note that the price per scoop of any flavor is 99 cents. Therefore, allow the flavor and scoops to be set directly, but not the price! The price should be set automatically based on the number of scoops entered. Some other requirements i. A default constructor and a constructor with...

  • C++ Programming Assignment S Mammal Lab This lab's goal is to give you some practice using inheritance, virtual functions, pointers, dynamic memory allocation, random numbers, and polym...

    C++ Programming Assignment S Mammal Lab This lab's goal is to give you some practice using inheritance, virtual functions, pointers, dynamic memory allocation, random numbers, and polymorphism. To complete the lab implement the following steps: Create a class called Mammal. All mammals have a weight and a name, so its data should be the mammal's weight and name. Provide a default constructor that sets the mammal's weight to 0 and name to null, and another constructor that allows the weight...

  • In this lab you will convert lab5.py to use object oriented programming techniques. The createList and...

    In this lab you will convert lab5.py to use object oriented programming techniques. The createList and checkList functions in lab5.py become methods of the MagicList class, and the main function of lab6.py calls methods of the MagicList class to let the user play the guessing game.                              A. (4pts) Use IDLE to create a lab6.py. Change the 2 comment lines at the top of lab6.py file: First line: your full name Second line: a short description of what the program...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT