Question
Code in Csharp A cargo ship is a merchant ship that carries cargo, goods, and materials from one port to another. Ship cargo carries items
Code in Csharp
A cargo ship is a merchant ship that carries cargo, goods, and materials from one port to another. Ship cargo carries items of different types and weight. Each have a maximum limit of weight to carry and pass them from one port to another. Consider a scenario of Ship cargo which can carry an unlimited number of items, as long as they dont exceed the maximum weight of the cargo bay, 25 Tons (1 ton=1000KG), you need to implement ship cargo service:
Items carries by the cargo should have attributes such as Name, Weight, Value, Durability, and ID.
Ship cargo can carry an unlimited number of items, as long as their weight is less than 25 Tons. Add item on the inventory list after weight check.
Now classify the items by separating them into 3 distinct categories Equipable, Consumable or Weapon. (You must implement these 3 classes that are subclasses of Item and they must have at least 3 unique attributes in each subclass based on their categorization) e.g. in Weapon class it should have a license number associated with it, other dont required them, equitable may have some size and consumable may have some expiry date.
In main you will create only one array of items of dynamic size considering unlimited number of items can be loaded to ship but you will keep track of total weight which cant exceed limit of 25 Ton.
You need to provide the following methods for each class by creating a menu which provides the option to the user: Add, Remove, Search, Sort, and Display. Based on the user selection of item below functionality is required:
Add: Add function will be used to add an item in array based on the attribute/type entered by the user. First it will ask the user which type of item he/she wants to add and will require to input those specific attributes with general attributes of item.
Remove: Remove will delete the item from the array based on user input i.e. will ask item type first and then will let user to select unique attribute from 3 unique attributes related to that type of item for deletion and then user will input that attribute. For example, your program may ask license number in case of weapon deletion. (there r lots of items how can we ask for unique attribute) o Search: Search will find the item from the array and display the result if found. It will take input same as remove i.e. will ask specific attributes for search.
Sort: It will sort all the items in array, it will place equipable first then consumables and then weapon. For example, if there are 10 equipable in array then from index 0 to 9 there will be equipable and from 10th index consumable will start and so on. Display: Display will output all the items along with item details and their respective categories attributes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started