Giter Club home page Giter Club logo

slowlow269's Introduction

Slowlow269

Starting over slowly

slowlow269's People

Contributors

slowlowgi avatar

Stargazers

 avatar

Watchers

 avatar

slowlow269's Issues

Snip

Sure! Here's a code snippet in Swift that generates a list of items with mock data:

import Foundation

struct Item {
    let name: String
    let price: Double
}

func generateMockItems(count: Int) -> [Item] {
    var items: [Item] = []
    
    let names = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]
    let minPrice = 10.0
    let maxPrice = 100.0
    
    for _ in 0..<count {
        let randomIndex = Int.random(in: 0..<names.count)
        let randomName = names[randomIndex]
        let randomPrice = Double.random(in: minPrice...maxPrice)
        
        let item = Item(name: randomName, price: randomPrice)
        items.append(item)
    }
    
    return items
}

// Generate a list of 5 mock items
let mockItems = generateMockItems(count: 5)

// Print the generated items
for item in mockItems {
    print("Name: \(item.name), Price: $\(item.price)")
}

This code defines a Item struct with properties name and price. The generateMockItems function takes an input count and generates a list of Item objects with random names and prices within the given range. It then returns the generated list. Finally, the code generates a list of 5 mock items and prints their details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.