Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created and completed the Swift Fundemintal project #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
//: Next, learn how programmers can leave notes in code.
//:
//:[Previous](@previous) | page 3 of 7 | [Next: Comments](@next)
4 + 5
(5 + 9 * 7)
9 * 8 * 6
6 / 8
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@
//: Take a deep breath and move on to the next page.
//:
//:[Previous](@previous) | page 4 of 7 | [Next: When Things Go Wrong 😰](@next)
//34 + 56 + 230 ( sum of numbers)

34 + 56 + 230

200 + 34 + 45

// 200 + 34 + 45
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
//: Next, read all about your very recent past.
//:
//:[Previous](@previous) | page 6 of 7 | [Next: Wrapup](@next)
1000 / 6
//: Since there is an error, the playground stops running your code.\
//: Notice that there are no results displayed in the sidebar. 👉
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Next, find out how to put the results sidebar to better use.

[Previous](@previous) | page 2 of 7 | [Next: Calculations](@next)
*/



3
9
678
44
-333
987
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='rendered' executeOnSourceChanges='true'>
<playground version='6.0' target-platform='macos' display-mode='rendered' executeOnSourceChanges='true'>
<pages>
<page name='Introduction'/>
<page name='What Is a Playground?'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,23 @@ let numberOfTickets = 150

//:
//:[Previous](@previous) | page 10 of 14 | [Next: Exercise: Lottery Tickets](@next)
// Number Of Tickets
numberOfTickets

// Ticket Price
10

// Room Rental Fee
1000

// Poster Cost
40

// Total Ticket Value
numberOfTickets * 10

// Total Expenses
1000 + 40

// Total Income Of Show
(numberOfTickets * 10) - (1000 + 40)
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ let programmersCut = profit / 10 // This is the answer you want to get over 100!
let friendsCut = profit - programmersCut

//:[Previous](@previous) | page 11 of 14 | [Next: Exercise: What Fits on Your iPhone?](@next)
// Values you should edit
let ticketsSold2 = 300
let ticketPrice2 = 89
let printingCosts2 = 20
let advertising2 = 500

// Total takings
let totalTakings2 = ticketPrice2 * ticketsSold2

// Jackpot
let jackpot2 = totalTakings2 / 2

// Expenses
let totalExpenses2 = printingCosts2 + advertising2

// Profit
let profit2 = totalTakings2 - jackpot2 - totalExpenses2

// Distribution
let programmersCut2 = profit2 / 10 // This is the answer you want to get over 100! 👉
let friendsCut2 = profit2 - programmersCut2
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@


//:[Previous](@previous) | page 12 of 14 | [Next: Exercise: Fixing Your Morning](@next)
let iphonestorageInMegaBites = 8*1000
let iPhonestorageInMegaBites = 3*1000
let oneminutveideousedInMegabytes = 150

let minutsTofillThephone = (iphonestorageInMegaBites - iPhonestorageInMegaBites) / oneminutveideousedInMegabytes
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
- callout(Exercise): Create a constant for each activity you do in the morning before leaving home: things like `brushTeeth`, `uploadPhotos`, `chooseClothes`, `shower`, `goJogging`, `finishHomework`, `fixLunch`, and so on. Think about how many minutes each activity usually takes, and assign that value to each constant.
*/
let brushTeeth = 3
// Add more here...

let uploadphotos = 2
let chooseClothes = 10
let gitshower = 60
let goJogging = 30
let finishHomework = 60
let fixLunch = 60
//: - callout(Exercise): Find the total time of all the activities by adding up the constants. Try to adjust the values or add more activities until the total time looks reasonably close to the actual amount of time you spend getting ready on an average day.

let TotaltimeOfallTheActivities = brushTeeth + uploadphotos + chooseClothes + gitshower + goJogging + finishHomework + fixLunch


//: - callout(Exercise): Add up the constants again, but this time in separate groups: one group for things you have to do and another group for things you like to do.\
//:\
//:If there are things you don’t have to do and don't like to do, make a third group and go ahead and sum that one, too. \
//:\
//:Make a new constant for each group.


let GroubOflikeToDo = goJogging + gitshower + chooseClothes
let GroubOfdontlikeToDo = finishHomework + fixLunch
let GroubOfToDoAndDontLikeToDo = fixLunch + finishHomework + brushTeeth + goJogging

/*:
See what happens to your total time spent getting ready if you tweak the durations of the different activities. How short of a shower would you have to take in order to have more time to message your friends? Or go for a longer run? How much more time would you need if you decided to spend as long as you wanted doing all the activities you like best?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ let rhso = co - lhso


//: - experiment: Rewrite the code so that it makes sense without needing a note. Use meaningful names and comments.


let countorange = 14
let countWatermelons = 3
let orangeweigh = 100
let watermelonsWeigh = 200
let truckorange = countorange * orangeweigh
let truckwatermelons = countWatermelons * watermelonsWeigh

let trucktotal = truckorange * truckwatermelons
let eachSide = trucktotal / 2
let leftHandSide = eachSide/orangeweigh
let rightHandside = countorange - leftHandSide



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,24 @@ let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters
//: Next, learn about choosing names.
//:
//:[Previous](@previous) | page 6 of 14 | [Next: Choosing Good Names](@next)
let TotalNumberOfMammals=2+5+1

let tOtalNumberOfMammals=17-5

let numberOfDogs2 = 6 + 2

let numberOfCats2 = 5 - 1

let numberofpig = 1

let numberoffish = 1

let numersnak = 1

let numberOfTurtles2 = 2 + 1

let numberOfHamsters2 = 1 + 1

let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters + numersnak+numberoffish+numberofpig

let totalNumberOfMammals2 = numberOfDogs + numberOfCats + numberOfHamsters
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ let numberOfHamsters = 1
let totalNumberOfAnimals = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters

let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters

//: Now it will be much easier — and less error-prone — to update the number of a certain kind of animal. You only have to update the value where the constant is defined.
//:
//: You can even let the playground do the math for you by adding or subtracting on the right hand side of the equal sign. For example, if two more people were bringing a dog, instead of changing the 6 to an 8, you could type:
Expand All @@ -35,3 +34,14 @@ let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters
//: Once you’re finished experimenting, move ahead.
//:
//:[Previous](@previous) | page 4 of 14 | [Next: Typing Names and Autocompletion](@next)
let numberOfDogs2 = 6 + 2

let numberOfCats2 = 5 - 1

let numberOfTurtles2 = 2 + 1

let numberOfHamsters2 = 1 + 1

let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters

let totalNumberOfMammals2 = numberOfDogs + numberOfCats + numberOfHamsters
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@
//: Could there be a better way to solve this problem? Think about it for a minute or two, then move on.
//:
//:[Previous](@previous) | page 2 of 14 | [Next: Pet Problem Recap](@next)
// Number of hamster
1
// Number Of Dogs
6

// Number Of Cats
5

// Number Of Turtles
2
// Total Number Of Animals
6 + 5 + 2

// Total Number Of Mammals
5 + 4 + 1

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='rendered' executeOnSourceChanges='true'>
<playground version='6.0' target-platform='macos' display-mode='rendered' executeOnSourceChanges='true'>
<pages>
<page name='Introduction'/>
<page name='Pet Problem'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ let finishedMessage = username + " " + likesYourPostMessage
//: Next, find out how building strings by adding them can get complicated.
//:
//:[Previous](@previous) | page 5 of 16 | [Next: Fill In The Blanks](@next)
let firstName = "Nada"
let lastName = "Abdullah"
let myname = firstName + " " + lastName
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ let traditionalGreeting = "Hello, world!"
//: Next, take a string-based trip around the world.
//:
//:[Previous](@previous) | page 3 of 16 | [Next: Unicode](@next)
let favoriteMovie = "her"
let favoritSong = "sorry"
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ let customerOrderSix = "小笼包"
- callout(Exercise):
Make sure the server repeats the order correctly *without* copying and pasting or retyping any of the orders.
*/
let serverResponseToTableTwo = "Let me make sure I've got this right: <Enter the Order Here>"
let serverResponseToTableTwo = "Let me make sure I've got this right: <돌솥비빔밥,Pasztecik szczecińskiand 小笼包>"

let tableTwoResponse = "Perfect, merci bien."
let tableTwoResponse = "돌솥비빔밥"



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@
_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._
*/
//:[Previous](@previous) | page 16 of 16
let totaliphoneStorge = 8 * 1000
let iphonesStorgaused = 3 * 1000
let oneMintsOfVideo = 150
let minutsOfVideoToFillipphon = (totaliphoneStorge - iphonesStorgaused)/oneMintsOfVideo
let user = " you can record \(minutsOfVideoToFillipphon)more minutes video."
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ let song = "\(refrain)\n\(refrain)\nYes, \(refrain)"

//:
//:[Previous](@previous) | page 15 of 16 | [Next: Exercise: Displaying Values](@next)

let SchoolName = "fictional school"
let Refrain = "vaa vaaa VVAA vaa-vaa \(schoolName) vaa vaa VAAAA"
let Song = "\(refrain)\n\(refrain)\nYes, \(refrain)"

Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ let newline = "Making new lines"

//:
//:[Previous](@previous) | page 13 of 16 | [Next: Exercise: A Restaurant](@next)
let thingsyouvelearned = """
\(constants) = " Declaring string constants "
\(unicode) = " Unicode characters (😎) "
\(combining) = "Combining strings using + "
\(interpolation) = "String interpolation (aka Fill in the Blanks)"
\(escaping) = "Escape characters for \"special powers\""
\(newline) = "Making new lines"
"""
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ let goalieReportString = "At the game yesterday, \(goalieName) had \(firstHalfSa
*/
// Add your version of the story below

let Name = "Maha"
let number = 100
let noun = "chocolate "
let adjective = "tasty "
let place = "France"
let noun2 = "DisneyLand"
let positiveemotion = "happy"
let negativeemotion = "sad"


let Samplestory = "Today was a big day for \(Name) They had finally saved up \(number) dollars and were going to buy a , \(adjective + noun) . They went to the \(noun2 + place) feeling very \(positiveemotion) But then they felt \(negativeemotion). They were all out of \(noun2)!"


//:
//:
//: Next you’ll see a few more tricks with strings.
//:
//:[Previous](@previous) | page 9 of 16 | [Next: The Great Escape](@next)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ let reason = "tasty"

// Define a string below in the pattern "I like ___ because it is ___."


let FavoriteFood = "orange"
let Reason = "healthy"
let WelcomeString = "i like \(FavoriteFood), because \(Reason)"
//: On the next page, see what happens with long strings.
//:
//:[Previous](@previous) | page 7 of 16 | [Next: Viewing Playground Results](@next)
2 changes: 1 addition & 1 deletion 03 Strings/Strings.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='rendered' executeOnSourceChanges='true'>
<playground version='6.0' target-platform='macos' display-mode='rendered' executeOnSourceChanges='true'>
<pages>
<page name='Introduction'/>
<page name='Characters'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ func rowTheBoat() {
What happens if you call your function more than once?

*/





func worke () {
print (" nume of employees" )
print ( " age of employees")
print ( "Mohammed,ahmed, saeed,fahad")
print ("20,30,35,45")
}


//: Next, learn about how to think about tasks and divide them up in a way that makes sense.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ breatheBetweenVerses()
rowTheBoat()
//: - callout(Exercise): Write a function called `crocodileScream()` for the second two lines of the second verse, and call it to complete the song in the console.


func crocodileleScream() {



Expand Down