Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object-Oriented Programming in java language . hurry, please. Thank you. public class HeavyTruck { public String name; public int numberOfTyres; public int loadAmount; private int

Object-Oriented Programming in java language . hurry, please. Thank you.

image text in transcribedimage text in transcribed

public class HeavyTruck { public String name; public int numberOfTyres; public int loadAmount; private int maxLoad; public Truck(String name, int not, int maxLoad) { this.name = name; this.numberOfTyres Enot; this.maxLoad = maxLoad; void load(int newLoad) { // this method must increment loadAmount with respect to given newload. It should throw illegal //argument exception with a message if load amount is greated than newLoad. // bu yntem, verilen newLoad'a gre loadAmount'u artrmaldr. Yklene niktar newLoad'dan bykse, bir mesajla geersiz argman istisnas atmaldr. } public class Garbage Truck { public String name; public int numberOfTyres; public int loadAmount; private int maxLoad; public Truck(String name, int not, int maxLoad) { this.name = name; this.numberOfTyres Enot; this.maxLoad = maxLoad; } void load (int newLoad){ // same as the other load method) } public class Tanker Truck { public int numberOfTyres; public String name; public int loadAmount; private int maxLoad; public Truck (String name, int not, int maxLoad) { this.name = name; this numberOfTyres anot; this.maxLoad maxLoad; void load(int newLoad){ // same as the other load method}} Question: There are 3 classes on the right where many codes have been repeated. This is a problem. We don't want this. So, a) Using OOP inheritance and polymorphism principles, rewrites the codes to reuse existing codes. b) Create a class called Factory where there will be an array of trucks. Constructor must take the array as parameters. Write a method in Factory class to compute all loads of the trucks in the Factory. Write another method to print all loads. c) In main method, create a Factory object and let it compute all loads and print them. Soru Verilen Classlarda cok fazla kod tekrar var. Bu bir sorundur. Gelitirici olarak bu istemediimiz bireydir. a) OOP miras ve polimorpfhism ilkelerini kullanarak, mevcut kodlar tekrar tekrar kullanabilen kodlar yeniden yaznz. b) Bir Truck dizisi ieren Factory adl bir sinif oluturun. Yapc (constructor), diziyi parametre olarak almaldr. Factorydeki trucklarin tm yklerini hesaplamak iin Factory snfnda bir yntem yazn. Tm ykleri yazdrmak iin baka bir yntem yazn. c) main methodda, bir Factory nesnesi oluturun ve tm Factorydeki ykleri hesaplatin ve yazdrn

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago