[Solved] CS2124 Homework5-Intro to Computer Science

$25

File Name: CS2124_Homework5_Intro_to_Computer_Science.zip
File Size: 395.64 KB

SKU: [Solved] CS2124 Homework5-Intro to Computer Science Category: Tag:
5/5 - (1 vote)

Write up the answers to questions 1 and 2 in a text document. Submit a .swift file for question 3, and another for question 4 1) What is the difference between: a) a type and an instance

  1. a function definition and a function call
  2. a struct and a class
  3. a parameter and an argument
  4. a property and a method
  • Think of a real-world object and its properties. Make up some actions or behaviors that the object might be able to perform. Write them in plain English.
  • Using a struct, create a new type for the real-world object you thought of for 2) with the properties and methods you thought of. Remember to mark each property with a let or var depending on whether or not it will be allowed to change. If you are not sure how to implement the body of one of the methods, describe what the method should do in a comment.

Use the stuct to make a new instance of your type.

Hint: If you made any properties with custom types, you can create placeholder types that have empty implementations. (See the TrainingShoe example)

  • Write your own Date type with the following properties / methods
Properties Methods
month asShortString() -> String
day asLongString() -> String
year dateAfter(days : Int) -> Date

It should have an initializer that takes month, day, and year as Integers.

Here is an example of how to use this class:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS2124 Homework5-Intro to Computer Science[Solved] CS2124 Homework5-Intro to Computer Science
$25