1. Create a class named Shirt with data fields for collar size and sleeve length. Include a constructor that takes arguments for each field. Include a class variable material and initialize it as...

1. Create a class named Shirt with data fields for collar size and sleeve length. Include a

constructor that takes arguments for each field. Include a class variable material and

initialize it as “cotton”. Write a client program to instantiate two objects from the class

with different collar size and sleeve length. Display all data including type of material for

each shirt. Use method shirtDisplay() to display the data.

2. The Computer Science Division will be organizing a software design competition and you

are required to create an application to capture the registration information. You are

required to create the following class named CompetitionEntry. The class has the
following members:
• two privates attributes : projectTitle (String) and teamSize(int)
• one class attribute feePerParticipant (double) with initial value of RM6.50
• a non-argument constructor that initializes as below:
projectTitle = “N/A”;
teamSize = 0;

• An overloading constructor that initializes the attributes using the incoming

arguments (3 marks)
• Mutator and accessor method for attribute teamSize. Ensure that teamSize takes

only positive value.
• A computeTeamFee() method that returns the total fee by multiplying teamSize with

feePerParticipant
Write a program to create CompetitionEntry object defined above and initialize the

object (using constructor) with the following values: “Super Tech” for title and team size

is 5. Display the total team fee on screen. Change the team size to 6 and display the total

team fee again. Use the object methods to change the values and display the output.
3. Write the following classes to show the concept of object composition:
A class Engine with two private data fields: type (String) and horsepower (double). It has

setter and getter methods for the private variables.

A class Car that has two private data fields: engine (Engine) and model (String). It has

getter and setter methods for the two private variables. The setter method for variable

engine takes the Engine type as the argument whereas the getter method for variable

engine returns the engine of a car
Produce a client program that creates objects of Car and Engine. The program reads the

required data from the user to initialize both objects. The program then displays the

details of the car including its horsepower and type of engine on screen.
Oct 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here