A big part of using classes in Java is thinking about the design of the class. You’ll need to figure out what information needs to be in the blueprint. So far we’ve seen a handful of examples. In our Rectangle class, we needed to know the width and height. For our Student class, we needed to know the first name, last name, and grade level.
This exercise is a free response question. Imagine that someone comes to you and asks you to design a class that represents a Pizza. What instance variables should the Pizza class have? Why? What are the types of those instance variables?
Your job in this exercise is write down some of the differences between objects and primitives. What is an object, and what is a primitive? How are they stored differently? How do we compare objects to each other? How do we compare primitives to each other?
Write down your answers to these questions in the space provided. If you need a refresher on the differences between objects and primitives, rewatch the Objects vs Primitives video.
Data Structures are a fundamental building block of programming and computer science. Not surprisingly, they are a crucial part of the Java programming language. In any application that you use, there are data structures at work behind the scenes.
Choosing data structures and designing classes are often the most important decisions you’ll make when writing a large program. For example, think about your cell phone – how should it store your text messages? How should it store all the apps on your phone? And what about the location of the apps? And your phone book?
Online mapping applications are another great example. If you want to look up a location, how should the mapping program store that location? What data structures does the application need in order to find directions from one place to another?
In this exercise, you should come up with some software application you use (a website, game, or other application) and write a few paragraphs describing what data structures you think it uses behind the scenes to make it work.
An algorithm is a step-by-step process to solve a problem. In this course you will program the computer to execute an algorithm, but you could also see an algorithm as something you do every day.
Come up with an example of an algorithm from your every day life and write a few paragraphs explaining the process, the problem, and the algorithm.