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

  Implement a program for this machine

Implement a program for this machine - design a special ATM machine to be used by needy people.

  How is the scope resolution operator use in class definition

How and why is the scope resolution operator :: used in class definitions? Which member functions are created automatically by the compiler if they are not included (by the programmer) in the class definition?

  Modify the program in 6a so that, in addition to the cents

Modify the program in 6a so that, in addition to the cents, the user enters the denomination of the coin to which to convert the pennies, such as 5 for nickles or 25 for quarters.

  You are required to prepare a program for assessment system

you are required to prepare a program for assessment system of a university. the main idea is to evaluate the gpa

  Program that stores a series of numbers in a binary tree

Write a program that stores a series of numbers in a binary tree

  Compare and contrast the meaning ofenterprise architecture

Compare and contrast the meaning ofenterprise architecture versusdistributed system? Provide at least 1 example each of enterprise architecture and a distributed system? Discuss the advantages and disadvantages of distributed systems in a business en..

  The program should support a ''new'' feature

Write a GUI program that represents a simple Notepad clone. The program should support a 'new' feature that clears the text buffer, a save feature that writes to a file using a PrintStream

  Expected profit per warranty

If the store charges $15 for the extended warranty, what will their expected profit per warranty be? If the company sells 100,000 projectors and 15% of the customers purchase the extended warranty, what will their expected profits from extended wa..

  Create if-then statement with single alternative decision

Create the If-Then statement (or a flowchart with a single alternative decision structure) which assigns 20 to  variable y and allots 40 to variable z if variable x is greater that 100.

  Write a webservices application that does a simple four

write a webservices application that does a simple four function calculator. write a cgi program launched by your

  Write recursive method to print all permutations of a string

Write a recursive method to print all the permutations of a string. For instance, for a string abc, the printout is: abc acb bac bca cab cba. Use the following two methods, the second one being a helper method.

  The above array is a declaration of an array of type integer

The above array is a declaration of an array of type integer. The name of the array is studentMark, and the array is of size 10. Arrays in C can be initialized by using a single statement that declares the array or by breaking it into two statements...

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