Free Essay

Wek 8 Object Oriented Programming

In:

Submitted By robert22
Words 390
Pages 2
Making Kool-Aid
-Kool-aid
-Sugar
-Water

Public Class Kool-aid
//attributes of kool-aid
Declare Flavors as String
Declare Cherry as String
Declare Lemonade as String
Declare Grape as String
Declare UserInput as string
Declare Two_packs as Bool
Declare One_Pack as Bool
IF UserInput != “Cherry” Set Flavors = Cherry
IF UserInput != “Grape” Set Flavors = Grape
Else
Set Flavors = Lemonade as Deflault
IF One_Pack = True Call Sugar()
IF Two_Pack = True Call Sugar()
End Class

Public Class Sugar
//Attributes of Sugar
Declare Sugar as Float
Declare OnePack as Int
Declare TwoPacks as Int
Declare Input as String
Declare newWater as new Water()
Set OnePack = 2 cups
Set TwoPack = 4 cups
IF Input = “1” Set Sugar = OnePack
IF Input = “2” Set Sugar = TwoPack

Public Class Water
//Attributes of Water
Declare newOnePack as Int
Declare newTwoPack as Int
Set newOnePack = ½ gallon
Set newTwoPack = 1 gallon

Main Module Declare Flavors as new Kool-aid.Flavors() Declare userSugar as new Sugar() Declare userWater as new Water()
Declare yes as String
While yes = “yes” Display “What flavor of Kool-Aid would you like? Cherry, Lemonade, or Grape” Input Flavors IF Flavors != “Cherry” or “Lemonade” or “Grape” Display “You have Chosen” + Flavors Display “Is this correct? Yes = Y or No = N” Else Display “You have not chosen a correct Flavor” End IF Display “How Many Packs of Kool-Aid did you use? 1 or 2” Input userSugar IF userSugar = “1” Set userWater = newOnePack IF userSugar = “2” Set userWater = newTwoPack End IF Display “Would you like to make more Kool-aid? yes or no”
Input yes
End While End Program

I believe I enjoy object oriented programming a lot more then structured because with OOP I can develop classes to store the data rather than using modules to call the functions that I am using I can just use the class file and create a new variable and inherit the attributes of the class file without having to store multiple lines of code to develop the same process and I can also use multiples of the same class with different variable names and label them as different functions and names OOP is used in game programming to store data regarding players and monsters movements, attacks, and items they can carry. Structured programming is good to use when creating smaller programs with little features with the program itself.

Similar Documents

Premium Essay

Organizational Behavior

...ORGANIZATIONAL BEHAVIOR CONCEPTS CONTROVERSIES APPLICATIONS Seventh Edition Stephen P. Robbins 1996 Contents Part One • Introduction Chapter 1 What Is Organizational Behavior? 2 Chapter 2 Responding to Global and Cultural Diversity 42 Part Two • The Individual Chapter 3 Foundations of Individual Behavior 80 Chapter 4 Perception and Individual Decision Making 130 Chapter 5 Values, Attitudes, and Job Satisfaction 172 Chapter 6 Basic Motivation Concepts 210 Chapter 7 Motivation: From Concepts to Applications 250 Part Three • The Group Chapter 8 Foundations of Group Behavior 292 Chapter 9 Understanding Work Teams 344 Chapter 10 Communication 374 Chapter 11 Leadership 410 Chapter 12 Power and Politics 460 Chapter 13 Conflict, Negotiation, and Intergroup Behavior 502 Part Four - The Organization System Chapter 14 Foundations of Organization Structure 548 Chapter 15 Technology, Work Design, and Stress 588 Chapter 16 Human Resource Policies and Practices 634 Chapter 17 Organizational Culture 678 Part Five - Organizational Dynamics Chapter 18 Organizational Change and Development 714 CHAPTER I • WHAT IS ORGANIZATIONAL BEHAVIOR? What Managers Do Let’s begin by briefly defining the terms manager and the place where managers work—the organization. Then let’s look at the manager’s job; specifically, what do managers do? Managers get things done through other people. They make decisions, allocate resources, and direct the activities of others to attain goals. Managers do...

Words: 146017 - Pages: 585