You are provided with a Person
class. This class has private properties name
, phoneNumber
and city
, along with their getter and setter methods.
- Write a method called
checkSameCity
which accepts one parameter of typePerson *
and checks if they live in the same city. The function should return a boolean value. - A Person has recently had a child, whose name is 'Abc'. Write a method called
registerChild
which takes 0 parameters and returns a newPerson *
instance represeting the child, which has the samephoneNumber
andcity
as the parent.
The Roman General Julius Caesar used to correspond with his generals using a secret code. He devised a way of encrypting his messages using a simple encryption scheme now known as Caesar Cipher or Shift Cipher. You can read more about it here and watch a video here
- You are given a class called
CaesarCipher
with methodsencode
anddecode
- Being amateur codebreakers, we want to know if two distinct looking ciphers correspond to the same input message. Write a method called codeBreaker, which accepts two cipher strings as paramaters and returns a boolean value which tells us whether they are actually the same input message encoded using two different offsets. hint: the maximum offset is 25
- There are multiple ways to do this. Try to come up with as many solutions as you can.
Example:
okmg = "mike", offset 2
tprl = "mike", offset 7Both are the same input message, but different offset. Your method would return YES in this case
You are given 3 classes
- ElectionManager
- Conducts an election.
- Controls start of voting
- Election
- Maintains a list of contenders
- Contender
- Represents details about a contender
- What is the contender's name?
- How many votes has he received?
Write a program to simulate an election. Create a class called VotingSimulator. In the main
function, you are required to do the following:
- Create an Election object, and given the Election a
name
- Create a few Contender objects. Add these to the Election object. Make sure that the contender names are distinct!
- Create a ElectionManager object. Ask it to manage the Election object created above.
- Ask the ElectionManager to initiatePolling
- Follow the instructions on the console. After each round of polling you will be asked(within the console) whether you want to continue or not.
- Ask the ElectionManager to displayResults
comment for branch