Question

2. Consider a car manufacturer that assembles different trim levels of a car: i) Basic has all the basic features of a car ii

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

BasicCar CarColor: String 写CarName: String Assemble(): BasicCari D Interface ICar 육Assembe(): ICar LuxuryCar 弓LeatherCoverCol

Class diagram for the given requirement has been attached, the implementation can be done using a factory pattern and so as to maintain the type safety.
Explanation:
ICar is an interface, which can be used for the implementation of the factory pattern, so as to maintain type safety.
BasicCar: This will contain all the basic attributes and the methods, the assemble method will give out the basic car.
LuxuryCar: It inherits the basic car to get the basic features of the car and calls the base assemble method to derive a basic car and then builds it up with special features to give a luxury car.
UltimateCar: It inherits the luxury car to get the luxury features of the car and calls the base assemble i.e., luxury car assemble method to derive a luxury car and then builds it up with special features to give a ultimate car.

B. Answer to instantiate the car

public static void main(String[] args)
{
ICar luxuryCar = new LuxuryCar();
luxuryCar.Assemble();
ICar ultimateCar = new UltimateCar();
ultimateCar();

}

As per my understanding, I have answered this, if there is much required and if you let me know your requirements, I can give you the better solution.

Add a comment
Know the answer?
Add Answer to:
2. Consider a car manufacturer that assembles different trim levels of a car: i) Basic has...
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
  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • I need this in C++. This is all one question Program 2: Linked List Class For...

    I need this in C++. This is all one question Program 2: Linked List Class For this problem, let us take the linked list we wrote in a functional manner in a previous assignment and convert it into a Linked List class. For extra practice with pointers we'll expand its functionality and make it a doubly linked list with the ability to traverse in both directions. Since the list is doubly linked, each node will have the following structure: struct...

  • Project 7: Vehicles 1 Objective In the last couple projects, you’ve created and used objects in...

    Project 7: Vehicles 1 Objective In the last couple projects, you’ve created and used objects in interesting ways. Now you’ll get a chance to use more of what objects offer, implementing inheritance and polymorphism and seeing them in action. You’ll also get a chance to create and use abstract classes (and, perhaps, methods). After this project, you will have gotten a good survey of object-oriented programming and its potential. This project won’t have a complete UI but will have a...

  • 1. According to the paper, what does lactate dehydrogenase (LDH) do and what does it allow...

    1. According to the paper, what does lactate dehydrogenase (LDH) do and what does it allow to happen within the myofiber? (5 points) 2. According to the paper, what is the major disadvantage of relying on glycolysis during high-intensity exercise? (5 points) 3. Using Figure 1 in the paper, briefly describe the different sources of ATP production at 50% versus 90% AND explain whether you believe this depiction of ATP production applies to a Type IIX myofiber in a human....

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

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