Create a base class called ship

Assignment Help Basic Computer Science
Reference no: EM131417113

OO Design

Our battleships game needs several different kinds of ship - we need a type to store the ships and information about it.

Create a base class called Ship

Create child classes for each of the ship types in the game (https://en.wikipedia.org/wiki/Battleship_(game)#Description) that inherit from Ship

Ships should have the following properties
- A private array of positions
  o A Position is composed of an X and Y coordinate - you should create a struct to encapsulate this
- A read only length
  o The constructor for each inherited type should set this to the correct length for the ship type
- A read only color to be drawn in
  o The constructor for each inherited type should set this to a different ConsoleColor for drawing
- A flag called Sunk
  o This should default to false for all ships
- A property called IsBattleship
  o This property should be overridden by each child type. Only the BattleShip should return true.
- A method called Reset
  o This method should reset the members to their empty defaults
- A method called Place(Position start, Direction direction)
  o Direction should be an enumeration of either Horizontal or Vertical
  o This will complete the Position array with the set of coordinates that the ship is covering
e.g Place(new Position(1, 1), Direction.Horizontal) on a patrol boat will fill the array with the points (1, 1) and (2, 1)

Notes:
- This is a separate program from previous weeks. You do not need to consider or implement anything to do with the grid or guessing
- You should choose the correct types and access modifiers for each type.
Create a test program that can run code such as the following:
AircraftCarrier ac = new AircraftCarrier();
Console.WriteLine(ac.IsBattleShip);
ac.Place(new Position(1, 1), Direction.Horizontal);
ac.Reset();

You should write additional code to test all of the methods and ship types.

Given that the positions array is private how can you test that the values are correct?

Verified Expert

The task was to learn object orientated programming in c#. There is a base class ship and all the child classes inherit from it. Proper methods were implemented for classes. Access modifiers were taken care of. Testing was also done.

Reference no: EM131417113

Questions Cloud

Write a paper about patterns of world history description : Write a paper about Patterns of World History Description. You will write a 5 to 7 page research paper. (The title page and bibliography page do not count as part of the 5 to 7 pages. You need 5 to 7 full pages of text.)
Discuss why structure follows strategy : In light of the text and other online resources, discuss why structure follows strategy?  While this may be the main direction of the relationship, it is argued that strategy may at times follow structure too (but this effect is not as strong). Why w..
Research and analysis methods to demonstrate selected : Students will choose a company of their liking and use any of the 2 (qualitative or quantitative) research and analysis methods to demonstrate selected perceptions (approved by the faculty) of the company. This project requires you to research, re..
What is the principal function of the project sponsor : What is the principal function of the project sponsor. As North Americans, what features of other countries’ popular cultures do we absorb? Provide some examples. What role does maintenance of personal integrity play in the personal security arena? W..
Create a base class called ship : Our battleships game needs several different kinds of ship - we need a type to store the ships and information about it - Create a base class called Ship and Create child classes for each of the ship types in the game that inherit from Ship.
Survey analysis-entertainment survey : Using a newspaper article from the AIU library's full-text database: Newsstand (ProQuest), create a lecture (with citations) that includes the following:
Draw a histogram of the 200 sample means : Simulate 200 samples of n = 10 responses for HrsSleep. Show the commands you used, or explain how you did the simulation.- Draw a histogram of the 200 sample means.
Draw a boxplot of the ages for the entire dataset : Let H = highest age in the sample for samples of size n = 10. Explain whether any of the rules given in chapter provide information about the sampling distribution of H.
Critical path activities in a project schedule : Should the critical path activities in a project schedule be managed differently from noncritical path activities? Why?

Reviews

inf1417113

3/17/2017 5:45:56 AM

Awesome support consideration. I get what I request, and when there's a slight misconception of the necessities, the circumstance is settled immediately. Much obliged to you, genuinely spared me this semester!

inf1417113

3/17/2017 5:44:54 AM

This project needs to be done in c# and is due This project needs to be completed in c# Attached are the assignment requirements in word format. 21549058_1Week 3 assignment.docx

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd