1. Trang chủ
  2. » Hoá học lớp 10

Lập trình hướng đối tượng: Workshop 4 - Atom

2 62 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Design and code a main program that accepts information for up to 10 atomic elements and displays the atomic information in tabular format.. The program output might look something like[r]

(1)

Part C – Encapsulation Class Basics

Workshop 4: Atom LEARNING OUTCOME

Upon successful completion of this workshop, you will have demonstrated the ability

• to design and code a class for a simple object

• to write code that includes robust user input validation, and

• to write code that includes formatted program output

EXERCISE

Design and code a class named Atom that holds information about a single atom Place your class definition in a file named Atom.h

Include the following member functions in your design:

bool accept() - prompts for and accepts from standard input

• an integer holding the atomic number,

• a string of no more than three (3) characters holding the atomic symbol,

• a string of no more than twenty (20) characters holding the full name of the atom and

• a floating-point value holding the atomic weight

If any input is invalid, your function rejects that input and requests fresh data • void display() const - displays the atomic information on standard output

Design and code a main program that accepts information for up to 10 atomic elements and displays the atomic information in tabular format

(2)

The program output might look something like:

Ngày đăng: 09/03/2021, 05:48

Xem thêm:

TỪ KHÓA LIÊN QUAN

w