Java writing programs 3 Develop three classes representing p

Java writing programs:

3. Develop three classes representing “players”: soccer players, saxophone players, and MP3 players. Your classes should be in a package entitled my.players. Write a main method in a separate class that creates and prints instances of the three classes of players. This “main” class should not be in any package (a.k.a. the unnamed or default package).

4. Use packages to implement two classes both named Account: one should represent bank accounts, the other should represent computer user accounts. Write a main method in another class (in the default package) that creates and prints an instance of each class. Hint: You can’t import two classes with the same name, but there is another way to refer to classes in other packages. Second hint: lookup “fully qualified name” in the Java

5. Extra practice and review (not about naming and scope): Write a class TriangleTable. A TriangleTable is defined by an integer n > 0. There are n rows in the table. Row i (starting from 0) contains the numbers from i down to 0. For example, a TriangleTable of size 4 would look like the following: 1 0 2 1 0 3 2 1 0 Your class should have a method that prints the instance nicely (like above). Your program should create and print tables of size from 1 to 10.

Solution

3.

package my. Players
public class Soccer_players
{
public void printMsg()
{
System.out.println(“Printing soccer players”);
}
}

package my.players
public class Saxophone_players
{
public void printMsg()
{
System.out.println(“Printing saxophone players”);
}
}
}
package my.players
public class Mp3_players
{
public void printMsg()
{
System.out.println(“Printing mp3 players”);
}
}
}


import my.players.*;
class Test
{
public static void main(String args[])
{
Soccer_players s1 = new Soccer_players();
Saxophone_players s2 = new Saxophone_players();
Mp3_players s3 = new Mp3_players();
s1.p rintMsg();
s2.printMsg();
s3.printMsg();
}

}

Java writing programs: 3. Develop three classes representing “players”: soccer players, saxophone players, and MP3 players. Your classes should be in a package
Java writing programs: 3. Develop three classes representing “players”: soccer players, saxophone players, and MP3 players. Your classes should be in a package

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site