Create a new class called ships

Assignment Help C/C++ Programming
Reference no: EM131427921

OO Design and implementation

Our battleships game needs to store a set of ships

Create a new class called Ships

Ships should have the following properties
• A way to store a collection of the Ship class from last week
   o If you do not have working code from last week please ask your teacher.
   o Does the Ships class represent the IS-A (inheritance) or the HAS-A (composition) relationship? Design your class accordingly. Use a suitable generic collection classes.
• void Add(Ship)
   o This method that allows you to add a ship
   o The add method should validate that no ships are overlapping. How you do this is up to you to design. Feel free to discuss it in the forums but do not post code
   o If there is a collision this method should throw a suitable exception
• void Clear()
   o this method that allows you to reset the collection
• boolSunkMyBattleship{get; private set}
   o this readonly property returns true if the battleship has been sunk
   o The private set part is optional depending on how you implement it. But the property should be readonly to callers of the class
• bool Attack(int x, int y)
   o this method that attacks the collection of ships and marks any positions as hit
   o This should also mark the ship as Sunk if all positions are hit
   o The method should return an indication of a hit (true) or a miss (false)
   o Your attack method should validate x and y are positive integers and throw a suitable exception if they are not

You should choose the correct types and access modifiers for each type.

You may add as much code and data structures as you like to fulfill all of the requirements.

Create a test program that creates a Ships collection and populates it with some ships - you may hard code positions though your teacher will test the code with different ones so make sure to test your code well.

The Test code should ask the user for X, Y positions and attach the ship collection until the battleship is hit.

There is no need to output any UI but it might help you test if you do ;-) It does not have to look like a battleship game. Remember this is purely code to help you test your Ships data structure

Attachment:- Programming Assignment.zip

Reference no: EM131427921

Questions Cloud

What is an immutable characteristic : What is an "immutable characteristic"? List and explain the protectable characteristics.
Experience creativity and innovation : Discuss a example from your work experience where creativity and innovation were used to help your company gain a competitive advantage.
Products of combustion form gas layers : As the fire grows the products of combustion form gas layers across the ceiling. As the gases move across the ceiling away from the centerline of the plume they begin to recirculate.
Process analysis on the business : You sat in on his presentation and you have to admit that his business jargon is next level. However, you detected that he completed no process analysis on the business. Suddenly, you notice Rogers grinning at you from across the room. Man, he loo..
Create a new class called ships : Create a test program that creates a Ships collection and populates it with some ships - you may hard code positions though your teacher will test the code with different ones so make sure to test your code well.
Responsibilities of the front-line worker : 1. Describe the responsibilities of the front-line worker in an organization that uses a management systems approach to safety and health. How do the responsibilities of his or her supervisor and higher management help him or her to succeed?
Discuss one contingency plan : Discuss one contingency plan your company may have in place and how critical thinking may have played into that plan.
Analyze the case study for assignment : Analyze the case study for this assignment (Case Study 1 on page 397 of Organizational Change). Based on your analysis, write a 4-5 page report to Terry O'Reilly in which you provide your analysis and recommendations. Note: review the assignment rubr..
Select two social and cultural and environmental theories : Select two social, cultural, and environmental theories. Compare and contrast the two theories. Explain how each theory works to include its benefits and challenges. Describe a public health issue that could be addressed by each theory.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Where do you think cpp and coding games in cpp is headed

Where do you think C++ and coding games in C++ is headed in the next five years? How about in the next 10 years? Do you think there are any significant improvements that need to be made to the code to ensure its stability in an ever-changing techn..

  Draw the extensive-form version of game

Consider a game between Joe and Snake. This game takes place in the morning after Joe has had breakfast. Snake can do two things: fight Joe or not. He likes fighting with people who are feeling cowardly and gets a payoff of 1 if he does. Snake, howev..

  One time for the entire number set

You must run your program one time for the entire number set. Test for EOF (or use the function feof()) to know when to stop processing. You are to determine if each integer read is prime or not, and output the result to stdout

  Write a menu-driven program that maintains an address book

Write a menu-driven program that maintains an address book using a linked list. The address book must supports the following operations

  Program that compares the number of possible sequences

Write a c++ program that compares the number of possible sequences of the length L that can be generated. The program must output a formatted list comparing the number of possible sequences for L=5,6,7,8,9. given size N=9

  Write recursive function for binary search tree

Write a recursive member function level() for class template BST(Binary Search Tree) that determines the level in the BST at which a specified item is located. The root of the BST is at level 0, its children are at level 1, and so on.

  Problem on c++ tools

When working in teams (at most two students per team), send one solution file per team.

  Write a program to read in two arbitrary boolean expressions

Write a program in your favorite programming language to read in two arbitrary Boolean expressions and see if they represent the same function.

  Write a function named smallest that receives three integer

Write a function named smallest that receives three integer arguments and returns the smallest of the three values.

  What is y after the given switch statement is executed

What is y after the following switch statement is executed? What is the value in count after the following loop is executed? What is the printout of the following code?

  Write c function to perform complex addition and subtraction

Write C functions to perform complex addition, subtraction, multiplication, and division using the complex structure dis­ cussed in this chapter. Add these functions to the calculator program. You will have to allow the user to specify a complex v..

  Program that generates 50,000 random integers

Program that generates 50,000 random integers from 1 to 6 (inclusive). Count the number of times that each number occurs and output the totals

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