Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft CSharp Programming For The Absolute Beginner (2002) [eng].pdf
Скачиваний:
39
Добавлен:
16.08.2013
Размер:
15.71 Mб
Скачать

private void scrSize_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) {

picCritter.Size = new Size(scrSize.Value, scrSize.Value);

}

I changed the size property of picCritter to a new Size object with both a width and height equal to the current value of the scroll bar.

Summary

In this chapter you applied the OOP skills you have learned so far in this book. You have made the transition to Windows programming. You have learned how to build an interface using the IDE, but you have also learned what the Form Designer does as it creates code for you. You have been introduced to the very useful System.Windows.Forms and System.Drawing namespaces. You have learned how to set up the most critical types of controls on your forms, including text boxes, command buttons, scroll bars, and various kinds of selection devices. More importantly, you have learned how to explore the capabilities of any controls available in the Toolbox so that you can adapt to new controls when they are made available.

Challenges

Add new capabilities to the Visual Critter. Perhaps have it say something random each time it is clicked, based on its mood.

Integrate the visual interface with the critter object you wrote in Chapter 4, “Objects and Encapsulation: The Critter Program.” Use buttons to feed and play with the critter, and have the mood change (based on the hunger and happiness variables), with visual indicators of the critter’s satisfaction.

Design a visual interface for the Snowball Fight program from Chapter 5, “Constructors, Inheritance, and Polymorphism: The Snowball Fight.” Use buttons to throw snowballs, make snowballs, and move.

Design a graphical adventure story like the one in Chapter 2, “Branching and Operators: The Math Game.” Use text boxes, radio buttons, and other design elements to get user input.

Make a version of the Rock, Paper, Scissors children’s game. The user and the computer each choose between rock, paper, and scissors, and the computer determines a winner according to a simple formula: Rock breaks scissors, scissors cut paper, and paper covers rock. Let the user click buttons or picture boxes to make his or her choice, and have the computer choice selected randomly.

167

Соседние файлы в предмете Программирование на C++