Question: You will write a class that models a band member and use your class to update sales of band candy. 1. Draw a UML diagram
You will write a class that models a band member and use your class to update sales of band candy.
1. Draw a UML diagram of the BandMember class 8A: UML and fill in the variables/finals and methods.
| BandMember |
| List the instance variables in the constructor. |
| List the methods in the class. |
After drawing the diagram, write the BandMember class assuming a band member object is described by two pieces of instance data: name (a String) and boxesSold (an integer that represents the number of boxes of candy the member has sold in the band fundraiser). The class should have the following methods: o constructor receives one parametera String containing the name of the band member. This parameter should be assigned to the instance variable name. o The constructor should set boxesSold to 0. o method getName that returns the name of the band member (it has no parameters). o A method updateSales that takes an integer parameter representing the number of additional boxes of candy sold. The method should add this number to boxesSold. o toString method that returns a string containing the name of the band member and the number of boxes of candy sold in a format similar to the following: Joe: 16 boxes
2. Write a program that uses BandMember objects to track the sales of two band members over 3 weeks. Your program should do the following: o Set up two BandMember objects like this: BandMember drums = new BandMember(Joe); BandMember flute = new BandMember(Emma) o Prompt for and read in the number of boxes sold by each member for each of the three weeks, one week at a time. What type of loop should you use? o Your prompts should include the member's name as stored in the BandMember object. For example, Enter the number of boxes sold by Joe for Week 1: o For each member, after reading in the weekly sales, call the updateSales method to update the total sales for that member. o After processing 3 weeks of data, display the name and total sales for each member (Use the toString method here).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
