DOC PREVIEW
TRINITY CSCI 1320 - Grouping Data

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Grouping Data3-9-2012Opening DiscussionMinute essay comments:What does the map function do?If robots took over would it be like Terminator 4? Would I be up to leading the resistance?Would it be more efficient to make your own file writing code than using PrintWriter?Use of args: file names, flags, etc.Limits on files determined by OS.Does moving IcP #5 push back our schedule?Always close at end of file?Is there a backspace on typewriters?MoreWhy do Java libraries work? Other languages?What will automated cars do to car racing?Effective use of programming time.Educational programming mediums: Scratch and Alice.Collections normally in memory. Source is loading from disk.Virtual boyfriends/girlfriends.Duplicating Watson is relatively cheap. Service.IcP solutions.MidtermMedian = 77 (without EC)Distribution5 As7 Bs10 Cs5 Ds5 FsMotivationConsider things like a Point, a Student, a CD, or a Room in a text game.We can use a tuple to group pieces of data together, but this doesn't carry much meaning and leads to ugly, bug-prone code.We want a better way to express these groupings that carries more information.User Defined TypesThe general way we do this is to define our own types.For now we will just use these types to collect data together in a case class.This allows us to give meaning to the data with meaningful names.case class TypeName(field1:Type1,field2:Type2,...)Example:case class NBAPlayer(name:String, team:String, mins:List[Int], points:List[Int], rebounds:List[Int])InstantiationOnce we have defined a case class we can make new objects of that type in one of two ways.TypeName(expr1,expr2,...)Ornew TypeName(expr1,expr2,...)Example:var td=NBAPlayer(“Tim Duncan”, ”Spurs”, List(23,13), List(15,17), List(6,8))UsageWe can pull out values using dot notation and the name of the field.Example:println(td.name+” averages “+td.points.sum/td.points.length+” ppg”)The fields are vals so you can't change what they reference. You can only change their values if they are mutable.Copy MethodThere is a copy method on case classes that does what the name implies.It can take named arguments to change certain fields in the copy.Example:td=td.copy(mins=17::td.mins, points=15::td.points, rebounds=4::td.rebounds)Putting it TogetherIn the book I am building an example application of a grade book. I'd like to do something different in class so you see variety.Do you have any suggestions or do you want me to come up with something? (CPI handling, player stats, ...)Minute EssayWhat topics would you most like to have video lectures for?Imagine you live in a world of abundance where you can have anything that has been created without needing money, but people need to work to create new ideas/designs/technology/science/knowledge. What would you do with your


View Full Document

TRINITY CSCI 1320 - Grouping Data

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Grouping Data
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Grouping Data and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Grouping Data 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?